From 2491ecb688577115a8ac2eb6ca571b3c3a5d47d5 Mon Sep 17 00:00:00 2001 From: twhittock Date: Tue, 26 May 2020 11:36:44 +0100 Subject: [PATCH 1/2] Bromley Borough Council --- BromleyBoroughCouncil.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 BromleyBoroughCouncil.py 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) From ee29179fa9a310df9131c88ca86659974d77c60c Mon Sep 17 00:00:00 2001 From: twhittock Date: Tue, 26 May 2020 12:48:02 +0100 Subject: [PATCH 2/2] Added Bromley output --- outputs/BromleyBoroughCouncil.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 outputs/BromleyBoroughCouncil.json 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"}