diff --git a/BromleyBoroughCouncil.py b/BromleyBoroughCouncil.py new file mode 100644 index 0000000000..3f7135b98b --- /dev/null +++ b/BromleyBoroughCouncil.py @@ -0,0 +1,29 @@ +#!/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 URL +req = Request('https://recyclingservices.bromley.gov.uk/property/xxxxxxxxxx') +req.add_header('User-Agent', user_agent) + +fp = urlopen(req).read() +page = fp.decode("utf8") + +soup = BeautifulSoup(page, features="html.parser") +soup.prettify() + +data = {} + +for bins in soup.findAll("div", {"class" : 'service-wrapper'}): + binType = bins.h3.text.strip() + binCollection = bins.find('td', {'class': 'next-service'}) + if binCollection: # batteries don't have a service date or other info associated with them. + data[binType] = binCollection.contents[-1].strip() + +json_data = json.dumps(data) + +print(json_data) diff --git a/outputs/BromleyBoroughCouncil.json b/outputs/BromleyBoroughCouncil.json new file mode 100644 index 0000000000..11a05f6598 --- /dev/null +++ b/outputs/BromleyBoroughCouncil.json @@ -0,0 +1 @@ +{"Paper and cardboard": "27/05/2020", "Non-recyclable refuse": "27/05/2020", "Food waste": "27/05/2020", "Plastic, glass and tins": "02/06/2020", "Green Garden Waste (Subscription)": "02/06/2020"}