Skip to content

Instantly share code, notes, and snippets.

@paalbra
Last active July 31, 2021 12:11
Show Gist options
  • Save paalbra/0228d55a5ddb48d1d7f9df1be1ca3a06 to your computer and use it in GitHub Desktop.
Save paalbra/0228d55a5ddb48d1d7f9df1be1ca3a06 to your computer and use it in GitHub Desktop.
import re
import sys
import bs4
import requests
ref = sys.argv[1]
url = f"https://www.legelisten.no/leger/{ref}"
content = requests.get(url).text
soup = bs4.BeautifulSoup(content, features="html.parser")
element = soup.find("div", string=re.compile("\d+ personer"))
count = int(re.sub("\D", "", element.text.strip())) if element else 0
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment