Skip to content

Commit 68e3adf

Browse files
authored
Merge branch 'release_18_june' into fix-issue-1484
2 parents 18684fe + 086f29d commit 68e3adf

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

uk_bin_collection/tests/input.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"skip_get_url": true,
105105
"uprn": "766252532",
106106
"url": "http://avdcbins.web-labs.co.uk/RefuseApi.asmx",
107-
"wiki_name": "Buckinghamshire (Aylesbury Vale)",
107+
"wiki_name": "Buckinghamshire",
108108
"wiki_note": "To get the UPRN, please use [FindMyAddress](https://www.findmyaddress.co.uk/search). Returns all published collections in the past, present, future.",
109109
"LAD24CD": "E06000060"
110110
},
@@ -623,13 +623,14 @@
623623
"house_number": "2",
624624
"postcode": "CA13 0DE",
625625
"url": "https://www.allerdale.gov.uk",
626-
"wiki_name": "Cumberland (Allerdale)",
626+
"wiki_name": "Cumberland",
627627
"wiki_note": "Pass the house number and postcode in their respective parameters.",
628628
"LAD24CD": "E06000063"
629629
},
630630
"CumberlandCouncil": {
631-
"uprn": "100110734613",
632-
"url": "https://waste.cumberland.gov.uk",
631+
"postcode": "CA6 5PH",
632+
"uprn": "10009457328",
633+
"url": "https://waste.cumberland.gov.uk/renderform?t=25&k=E43CEB1FB59F859833EF2D52B16F3F4EBE1CAB6A",
633634
"wiki_name": "Cumberland",
634635
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
635636
"LAD24CD": "E06000063"
@@ -1360,7 +1361,7 @@
13601361
"skip_get_url": true,
13611362
"uprn": "12081498",
13621363
"url": "https://www.ealing.gov.uk/site/custom_scripts/WasteCollectionWS/home/FindCollection",
1363-
"wiki_name": "Ealing (London Borough)",
1364+
"wiki_name": "Ealing",
13641365
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search).",
13651366
"LAD24CD": "E09000009"
13661367
},
@@ -1828,8 +1829,8 @@
18281829
"OxfordCityCouncil": {
18291830
"postcode": "OX3 7QF",
18301831
"uprn": "100120820551",
1831-
"url": "https://www.oxford.gov.uk",
1832-
"wiki_command_url_override": "https://www.oxford.gov.uk",
1832+
"url": "https://www.oxford.gov.uk/xfp/form/142",
1833+
"wiki_command_url_override": "https://www.oxford.gov.uk/xfp/form/142",
18331834
"wiki_name": "Oxford",
18341835
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
18351836
"LAD24CD": "E07000178"
@@ -2804,4 +2805,4 @@
28042805
"wiki_note": "Provide your UPRN.",
28052806
"LAD24CD": "E06000014"
28062807
}
2807-
}
2808+
}

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

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)