Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Warwick District Council #18

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added outputs/WarwickDistrictCouncil.json
Binary file not shown.
38 changes: 38 additions & 0 deletions scripts/WarwickDistrictCouncil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
from urllib.request import Request, urlopen
import json
from bs4 import BeautifulSoup

user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
headers = {'User-Agent': user_agent}

#Replace XXXXXX
req = Request('https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/xxxxxxxxxx')
req.add_header('User-Agent', user_agent)

fp = urlopen(req).read()

page = fp.decode("utf8")

soup = BeautifulSoup(page, features="html.parser")
soup.prettify()

#Form a JSON wrapper
data = {"bins":[]}
for element in soup.find_all("strong"):

binType = element.next_element
binType = binType.lstrip()
collectionDate = element.next_sibling.next_element.next_element


dict_data = {
"type": binType,
"collectionDate": collectionDate,
}
data["bins"].append(dict_data)

json_data = json.dumps(data, indent=4)

print(json_data)