Skip to content

Instantly share code, notes, and snippets.

@salgo60
Created February 26, 2019 19:29
Show Gist options
  • Save salgo60/c29375d5c00fb256d1d90afd4982643f to your computer and use it in GitHub Desktop.
Save salgo60/c29375d5c00fb256d1d90afd4982643f to your computer and use it in GitHub Desktop.
Extract professors from KI using BeautifulSoup
"""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