Skip to content

Commit 1d01af1

Browse files
authored
Merge pull request #1491 from robbrad/release_18_june
2 parents 2051201 + 3fef70c commit 1d01af1

File tree

8 files changed

+2830
-2821
lines changed

8 files changed

+2830
-2821
lines changed

uk_bin_collection/tests/input.json

Lines changed: 2808 additions & 2807 deletions
Large diffs are not rendered by default.

uk_bin_collection/uk_bin_collection/councils/CumberlandCouncil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class CouncilClass(AbstractGetBinDataClass):
1616
def parse_data(self, page: str, **kwargs) -> dict:
1717

1818
user_uprn = kwargs.get("uprn")
19+
postcode = kwargs.get("postcode")
1920
check_uprn(user_uprn)
2021
bindata = {"bins": []}
2122

@@ -57,6 +58,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
5758
"TriggerCtl": "",
5859
"FF265": f"U{user_uprn}",
5960
"FF265lbltxt": "Please select your address",
61+
"FF265-text": postcode
6062
}
6163

6264
# print(payload)

uk_bin_collection/uk_bin_collection/councils/KingstonUponThamesCouncil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
5151
if row.find("dt").get_text().strip().lower() == "next collection":
5252
collection_date = remove_ordinal_indicator_from_date_string(
5353
row.find("dd").get_text()
54-
).strip()
54+
).strip().replace(" (In progress)", "")
5555
# strip out any text inside of the date string
5656
collection_date = re.sub(
5757
r"\n\s*\(this.*?\)", "", collection_date

uk_bin_collection/uk_bin_collection/councils/NorthHertfordshireDistrictCouncil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
151151

152152
# Looking for bin types in the exact HTML structure
153153
bin_type_elements = soup.select(
154-
"div.formatting_bold.formatting_size_bigger.formatting span.value-as-text"
154+
"div.page_cell.contains_widget:first-of-type div.formatting_bold.formatting_size_bigger.formatting span.value-as-text"
155155
)
156156
# print(f"Found {len(bin_type_elements)} bin type elements")
157157

uk_bin_collection/uk_bin_collection/councils/OxfordCityCouncil.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def parse_data(self, page: str, **kwargs) -> dict:
2121
check_postcode(user_postcode)
2222
bindata = {"bins": []}
2323

24-
session_uri = "https://www.oxford.gov.uk/mybinday"
25-
URI = "https://www.oxford.gov.uk/xfp/form/142"
24+
session_uri = "https://www.oxford.gov.uk/xfp/form/142"
25+
URI = "https://www.oxford.gov.uk/xfp/form/142#q6ad4e3bf432c83230a0347a6eea6c805c672efeb_0"
2626

2727
session = requests.Session()
2828
token_response = session.get(session_uri)
@@ -40,15 +40,18 @@ def parse_data(self, page: str, **kwargs) -> dict:
4040

4141
collection_response = session.post(URI, data=form_data)
4242

43-
collection_soup = BeautifulSoup(collection_response.text, "html.parser")
44-
for paragraph in collection_soup.find("div", class_="editor").find_all("p"):
45-
matches = re.match(r"^(\w+) Next Collection: (.*)", paragraph.text)
43+
soup = BeautifulSoup(collection_response.text, "html.parser")
44+
#print(soup)
45+
46+
for paragraph in soup.find("div", class_="editor").find_all("p"):
47+
matches = re.match(r"^Your next (\w+) collections: (.*)", paragraph.text)
4648
if matches:
4749
collection_type, date_string = matches.groups()
50+
parts = date_string.split(', ', 1)
4851
try:
49-
date = datetime.strptime(date_string, "%A %d %B %Y").date()
52+
date = datetime.strptime(parts[0], "%A %d %B %Y").date()
5053
except ValueError:
51-
date = datetime.strptime(date_string, "%A %d %b %Y").date()
54+
date = datetime.strptime(parts[0], "%A %d %b %Y").date()
5255

5356
dict_data = {
5457
"type": collection_type,
@@ -61,3 +64,5 @@ def parse_data(self, page: str, **kwargs) -> dict:
6164
)
6265

6366
return bindata
67+
68+

uk_bin_collection/uk_bin_collection/councils/RugbyBoroughCouncil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
113113
try:
114114
# Convert date from "Friday 09 May 2025" format
115115
parsed_date = datetime.strptime(
116-
collection_date, "%A %d %B %Y"
116+
collection_date, "%A %d %b %Y"
117117
)
118118
formatted_date = parsed_date.strftime("%d/%m/%Y")
119119

@@ -132,7 +132,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
132132
key=lambda x: datetime.strptime(x["collectionDate"], "%d/%m/%Y")
133133
)
134134

135-
print(bin_data)
135+
#print(bin_data)
136136

137137
except Exception as e:
138138
# Here you can log the exception if needed

uk_bin_collection/uk_bin_collection/councils/WiganBoroughCouncil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
8282
# Get the dates.
8383
for bins in soup.find_all("div", {"class": "BinsRecycling"}):
8484
bin_type = bins.find("h2").text
85-
binCollection = bins.find("div", {"class": "dateWrapper-next"}).get_text(
85+
binCollection = bins.find("div", {"class": "dateWrap-next"}).get_text(
8686
strip=True
8787
)
8888
binData = datetime.strptime(

wiki/Councils.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,10 @@ Note: Pass the house number and postcode in their respective parameters.
11581158

11591159
### Cumberland Borough Council
11601160
```commandline
1161-
python collect_data.py CumberlandCouncil https://waste.cumberland.gov.uk -u XXXXXXXX
1161+
python collect_data.py CumberlandCouncil https://waste.cumberland.gov.uk -u XXXXXXXX -p "XXXX XXX"
11621162
```
11631163
Additional parameters:
1164+
- `-p` - postcode
11641165
- `-u` - UPRN
11651166

11661167
Note: Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.
@@ -2682,7 +2683,7 @@ Note: Replace UPRN in URL with your own UPRN.
26822683

26832684
### Oxford City Council
26842685
```commandline
2685-
python collect_data.py OxfordCityCouncil https://www.oxford.gov.uk -u XXXXXXXX -p "XXXX XXX"
2686+
python collect_data.py OxfordCityCouncil https://www.oxford.gov.uk/xfp/form/142 -u XXXXXXXX -p "XXXX XXX"
26862687
```
26872688
Additional parameters:
26882689
- `-u` - UPRN

0 commit comments

Comments
 (0)