Skip to content

Commit 944f1b1

Browse files
committed
fix: #1557 - Adding East Dunbartonshire
fix: #1557 - Adding East Dunbartonshire
1 parent b12637c commit 944f1b1

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

uk_bin_collection/tests/input.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,13 @@
760760
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search).",
761761
"LAD24CD": "E07000040"
762762
},
763+
"EastDunbartonshireCouncil": {
764+
"uprn": "132027197",
765+
"url": "https://www.eastdunbarton.gov.uk/",
766+
"wiki_name": "East Dunbartonshire",
767+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
768+
"LAD24CD": "S12000045"
769+
},
763770
"EastHertsCouncil": {
764771
"LAD24CD": "E07000097",
765772
"skip_get_url": true,
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import requests
2+
from bs4 import BeautifulSoup, Tag
3+
4+
from uk_bin_collection.uk_bin_collection.common import *
5+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
6+
7+
8+
# import the wonderful Beautiful Soup and the URL grabber
9+
class CouncilClass(AbstractGetBinDataClass):
10+
"""
11+
Concrete classes have to implement all abstract operations of the
12+
base class. They can also override some operations with a default
13+
implementation.
14+
"""
15+
16+
def parse_data(self, page: str, **kwargs) -> dict:
17+
18+
user_uprn = kwargs.get("uprn")
19+
check_uprn(user_uprn)
20+
bindata = {"bins": []}
21+
22+
URI = f"https://www.eastdunbarton.gov.uk/services/a-z-of-services/bins-waste-and-recycling/bins-and-recycling/collections/?uprn={user_uprn}"
23+
24+
# Make the GET request
25+
response = requests.get(URI)
26+
27+
soup = BeautifulSoup(response.text, "html.parser")
28+
29+
table = soup.find("table", {"class": "bin-table"})
30+
31+
tbody = table.find("tbody")
32+
33+
trs = tbody.find_all("tr")
34+
35+
for tr in trs:
36+
tds = tr.find_all("td")
37+
bin_type = tds[0].get_text()
38+
collection_date_str = tds[1].find("span").get_text()
39+
40+
collection_date = datetime.strptime(collection_date_str, "%A, %d %B %Y")
41+
42+
dict_data = {
43+
"type": bin_type,
44+
"collectionDate": collection_date.strftime(date_format),
45+
}
46+
bindata["bins"].append(dict_data)
47+
48+
bindata["bins"].sort(
49+
key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
50+
)
51+
52+
return bindata

wiki/Councils.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ This document is still a work in progress, don't worry if your council isn't lis
100100
- [Eastbourne](#eastbourne)
101101
- [East Cambridgeshire](#east-cambridgeshire)
102102
- [East Devon](#east-devon)
103+
- [East Dunbartonshire](#east-dunbartonshire)
103104
- [East Herts Council](#east-herts-council)
104105
- [East Lindsey](#east-lindsey)
105106
- [East Lothian](#east-lothian)
@@ -1439,6 +1440,17 @@ Note: Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyadd
14391440

14401441
---
14411442

1443+
### East Dunbartonshire
1444+
```commandline
1445+
python collect_data.py EastDunbartonshireCouncil https://www.eastdunbarton.gov.uk/ -u XXXXXXXX
1446+
```
1447+
Additional parameters:
1448+
- `-u` - UPRN
1449+
1450+
Note: You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.
1451+
1452+
---
1453+
14421454
### East Herts Council
14431455
```commandline
14441456
python collect_data.py EastHertsCouncil https://east-herts.co.uk/api/services/ -s -u XXXXXXXX

0 commit comments

Comments
 (0)