Created
February 26, 2019 19:29
-
-
Save salgo60/c29375d5c00fb256d1d90afd4982643f to your computer and use it in GitHub Desktop.
Extract professors from KI using BeautifulSoup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Extract Professors at KI""" | |
from bs4 import BeautifulSoup | |
import requests | |
ki_url = "https://ki.se/en/research/professors-at-ki" | |
def get_ki_prof(url): | |
source_code = requests.get(url).text | |
soup = BeautifulSoup(source_code, 'html.parser') | |
i: int = 0 | |
for link in soup.find_all("a"): | |
href = link.get('href') | |
if href.startswith("/en/people"): | |
print(href,"|",link.string,"|",link.parent.nextSibling.string) | |
i += 1 | |
print("Number items in list: ", i) | |
get_ki_prof(ki_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment