Created
June 10, 2021 16:55
-
-
Save matty234/b82c309f16a7dd84a71c8bf340ba9237 to your computer and use it in GitHub Desktop.
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
import requests | |
from bs4 import BeautifulSoup | |
headers = {} | |
url = "https://www.gov.uk/guidance/red-amber-and-green-list-rules-for-entering-england" | |
req = requests.get(url, headers) | |
soup = BeautifulSoup(req.content, 'html.parser') | |
lists = {} | |
tables = soup.findAll( "table" ) | |
for table in tables: | |
head = table.find("thead").select("th")[0].getText().strip() | |
if head.endswith("list"): | |
splat = head.split(' ')[0] | |
found = [] | |
countryGroup = table.find("tbody").select("tr") | |
for c in countryGroup: | |
val = c.select("th")[0].getText().strip() | |
print(val) | |
found.append(val) | |
lists[splat.lower()]=found | |
print(lists) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment