uk_bin_collection 0.152.10__py3-none-any.whl → 0.152.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -641,6 +641,13 @@
641
641
  "wiki_note": "Pass the house number and postcode in their respective parameters. This parser requires a Selenium webdriver.",
642
642
  "LAD24CD": "E07000096"
643
643
  },
644
+ "DarlingtonBoroughCouncil": {
645
+ "uprn": "10003076924",
646
+ "url": "https://www.darlington.gov.uk/bins-waste-and-recycling/collection-day-lookup/",
647
+ "wiki_name": "Darlington Borough Council",
648
+ "wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
649
+ "LAD24CD": "E06000005"
650
+ },
644
651
  "DartfordBoroughCouncil": {
645
652
  "uprn": "100060861698",
646
653
  "url": "https://www.dartford.gov.uk/waste-recycling/collection-day",
@@ -245,25 +245,39 @@ class CouncilClass(AbstractGetBinDataClass):
245
245
  # extract table body
246
246
  for row in table.find_all("tr")[1:]:
247
247
  if row.find_all("td")[1].text.strip() == "Normal collection day":
248
- bh_dict[
249
- parse(
250
- row.find_all("td")[0].text.strip(),
251
- dayfirst=True,
252
- fuzzy=True,
253
- ).date()
254
- ] = parse(
255
- row.find_all("td")[0].text.strip(), dayfirst=True, fuzzy=True
256
- ).date()
248
+ try:
249
+ # Check for normal collection day (no change)
250
+ if row.find_all("td")[0].text.strip() == "Normal collection":
251
+ continue
252
+ else:
253
+ bh_dict[
254
+ parse(
255
+ row.find_all("td")[0].text.strip(),
256
+ dayfirst=True,
257
+ fuzzy=True,
258
+ ).date()
259
+ ] = parse(
260
+ row.find_all("td")[0].text.strip(), dayfirst=True, fuzzy=True
261
+ ).date()
262
+ except:
263
+ continue
257
264
  else:
258
- bh_dict[
259
- parse(
260
- row.find_all("td")[0].text.strip(),
261
- dayfirst=True,
262
- fuzzy=True,
263
- ).date()
264
- ] = parse(
265
- row.find_all("td")[1].text.strip(), dayfirst=True, fuzzy=True
266
- ).date()
265
+ try:
266
+ # Check for normal collection day (no change)
267
+ if row.find_all("td")[1].text.strip() == "Normal collection":
268
+ continue
269
+ else:
270
+ bh_dict[
271
+ parse(
272
+ row.find_all("td")[0].text.strip(),
273
+ dayfirst=True,
274
+ fuzzy=True,
275
+ ).date()
276
+ ] = parse(
277
+ row.find_all("td")[1].text.strip(), dayfirst=True, fuzzy=True
278
+ ).date()
279
+ except:
280
+ continue
267
281
 
268
282
  for refuse_date in refuse_dates:
269
283
  collection_date = (datetime.strptime(refuse_date, "%d/%m/%Y") + timedelta(
@@ -0,0 +1,68 @@
1
+ import re
2
+
3
+ from bs4 import BeautifulSoup
4
+
5
+ from uk_bin_collection.uk_bin_collection.common import *
6
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
7
+
8
+
9
+ # import the wonderful Beautiful Soup and the URL grabber
10
+ class CouncilClass(AbstractGetBinDataClass):
11
+ """
12
+ Concrete classes have to implement all abstract operations of the
13
+ base class. They can also override some operations with a default
14
+ implementation.
15
+ """
16
+
17
+ def parse_data(self, page: str, **kwargs) -> dict:
18
+
19
+ data = {"bins": []}
20
+
21
+ user_uprn = kwargs.get("uprn")
22
+ check_uprn(user_uprn)
23
+
24
+ url = f"https://www.darlington.gov.uk/bins-waste-and-recycling/collection-day-lookup/?uprn={user_uprn}"
25
+
26
+ # Referrer: https://www.darlington.gov.uk/bins-waste-and-recycling/collection-day-lookup/
27
+ # X-Requested-With: XMLHttpRequest
28
+ headers = {
29
+ "Accept": "*/*",
30
+ "Accept-Encoding": "gzip, deflate, br, zstd",
31
+ "Accept-Language": "en-GB,en;q=0.5",
32
+ "Referer": "https://www.darlington.gov.uk/bins-waste-and-recycling/collection-day-lookup/",
33
+ "Sec-Detch-Dest": "empty",
34
+ "Sec-Fetch-Mode": "cors",
35
+ "Sec-Fetch-Site": "same-origin",
36
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.186 Safari/537.36",
37
+ "X-Requested-With": "XMLHttpRequest",
38
+ }
39
+
40
+ # Make a BS4 object
41
+ page = requests.get(url, headers=headers)
42
+ soup = BeautifulSoup(page.text, features="html.parser")
43
+ soup.prettify()
44
+
45
+ # Loop over each date card
46
+ card_blocks = soup.select("#detailsDisplay .refuse-results")
47
+
48
+ for card in card_blocks:
49
+ bin_date_tag = card.select_one(".card-footer h3")
50
+ if not bin_date_tag:
51
+ continue
52
+
53
+ bin_type = card.select_one(".card-header h2").text.strip()
54
+ bin_date = bin_date_tag.text.strip()
55
+
56
+ # Remove any extra text from the date "(Today)", "(Tomorrow)"
57
+ cleaned_bin_date = re.sub(r"\s*\(.*?\)", "", bin_date).strip()
58
+
59
+ next_binfo = {
60
+ "type": bin_type,
61
+ "collectionDate": datetime.strptime(
62
+ cleaned_bin_date, "%A %d %B %Y"
63
+ ).strftime(date_format),
64
+ }
65
+
66
+ data["bins"].append(next_binfo)
67
+
68
+ return data
@@ -33,10 +33,9 @@ class CouncilClass(AbstractGetBinDataClass):
33
33
  "tr", {"class": "govuk-table__row"}
34
34
  ):
35
35
  week_text = week.get_text().strip().split("\n")
36
+ date_str = week_text[0].split(" - ")[0].split("–")[0].strip()
36
37
  collection_date = datetime.strptime(
37
- remove_ordinal_indicator_from_date_string(
38
- week_text[0].split(" - ")[0]
39
- ).strip(),
38
+ remove_ordinal_indicator_from_date_string(date_str),
40
39
  "%A %d %B",
41
40
  )
42
41
  next_collection = collection_date.replace(year=datetime.now().year)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.152.10
3
+ Version: 0.152.11
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -7,7 +7,7 @@ uk_bin_collection/tests/council_feature_input_parity.py,sha256=DO6Mk4ImYgM5ZCZ-c
7
7
  uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
8
8
  uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=SJK-Vc737hrf03tssxxbeg_JIvAH-ddB8f6gU1LTbuQ,251
9
9
  uk_bin_collection/tests/generate_map_test_results.py,sha256=CKnGK2ZgiSXomRGkomX90DitgMP-X7wkHhyKORDcL2E,1144
10
- uk_bin_collection/tests/input.json,sha256=TEBMKFjbR6llQIMVXw1KlkoSRUiWIp-Zbka4yARv2Kw,132602
10
+ uk_bin_collection/tests/input.json,sha256=JRZxMEtYTjeq26L4i0zU41U8qqHS4iLENdMv4bZWx6M,132955
11
11
  uk_bin_collection/tests/output.schema,sha256=ZwKQBwYyTDEM4G2hJwfLUVM-5v1vKRvRK9W9SS1sd18,1086
12
12
  uk_bin_collection/tests/step_defs/step_helpers/file_handler.py,sha256=Ygzi4V0S1MIHqbdstUlIqtRIwnynvhu4UtpweJ6-5N8,1474
13
13
  uk_bin_collection/tests/step_defs/test_validate_council.py,sha256=VZ0a81sioJULD7syAYHjvK_-nT_Rd36tUyzPetSA0gk,3475
@@ -73,7 +73,7 @@ uk_bin_collection/uk_bin_collection/councils/CastlepointDistrictCouncil.py,sha25
73
73
  uk_bin_collection/uk_bin_collection/councils/CeredigionCountyCouncil.py,sha256=np9iLnMVWpMYUiHZ4sJaSaU5pOWfmiCLQ8TIrOlY48o,5924
74
74
  uk_bin_collection/uk_bin_collection/councils/CharnwoodBoroughCouncil.py,sha256=FC8jftZFfMnqV-Of_eQAYBcUiCIJDSNFO2DMZbtDy6E,2569
75
75
  uk_bin_collection/uk_bin_collection/councils/ChelmsfordCityCouncil.py,sha256=thagz60NeEDbOHdnBH-ByKDBRNElPvo0UU0lwZ6c2OQ,3891
76
- uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py,sha256=bGxfMO4PpTd6ZTfm1hA9tmNUFDKGt20CMJolZ3K_CeM,16411
76
+ uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py,sha256=7W0MmXn0yXhryRg8rPVMvp1rilYHnYRfxpZ9UmATt24,17173
77
77
  uk_bin_collection/uk_bin_collection/councils/CherwellDistrictCouncil.py,sha256=h8jgpTra9H-aqfDB7tcOd8fveRcQXEXRUnG35SF7ARg,3484
78
78
  uk_bin_collection/uk_bin_collection/councils/CheshireEastCouncil.py,sha256=RoybPitUD4u0xk4Kc9hXqHbUXCqGJG9Z4uRHWKj4ttk,2495
79
79
  uk_bin_collection/uk_bin_collection/councils/CheshireWestAndChesterCouncil.py,sha256=5mKZf22NgdyBY-SqV0c2q8b8IJobkoZrsfGEVUcxUyM,3544
@@ -91,6 +91,7 @@ uk_bin_collection/uk_bin_collection/councils/CroydonCouncil.py,sha256=6UCT2Q75NA
91
91
  uk_bin_collection/uk_bin_collection/councils/CumberlandAllerdaleCouncil.py,sha256=bPOmkyzNnHrOtUprbouHdOsgpu7WilUADcaccWTCPFI,2839
92
92
  uk_bin_collection/uk_bin_collection/councils/CumberlandCouncil.py,sha256=PwTbTVNDdGZnSkPcIHYf-LHItDyIbR68Avr96T1FrX8,3308
93
93
  uk_bin_collection/uk_bin_collection/councils/DacorumBoroughCouncil.py,sha256=Tm_6pvBPj-6qStbe6-02LXaoCOlnnDvVXAAocGVvf_E,3970
94
+ uk_bin_collection/uk_bin_collection/councils/DarlingtonBoroughCouncil.py,sha256=5rv6xiGkqBrCP57dw2vkrqyQlSX6qhGj_uB2nKrkHL4,2448
94
95
  uk_bin_collection/uk_bin_collection/councils/DartfordBoroughCouncil.py,sha256=3vuXYhoK3ZkFGtxIDJXCTeY8_kbaXDcKn0C2yk5g1kI,2056
95
96
  uk_bin_collection/uk_bin_collection/councils/DenbighshireCouncil.py,sha256=FtG0LMTY21RBQiBpeX4FihdMCEZ1knpARYyMfyCn9ng,2103
96
97
  uk_bin_collection/uk_bin_collection/councils/DerbyCityCouncil.py,sha256=M8FGLhZn9wdRCq1W6z_yqJQqeba3EKyba3vhM22MzB4,1883
@@ -243,7 +244,7 @@ uk_bin_collection/uk_bin_collection/councils/ReigateAndBansteadBoroughCouncil.py
243
244
  uk_bin_collection/uk_bin_collection/councils/RenfrewshireCouncil.py,sha256=VjjolGn0KemgIUnmF-JlB8gxNLyaQB5mP61NonxVJAo,5080
244
245
  uk_bin_collection/uk_bin_collection/councils/RhonddaCynonTaffCouncil.py,sha256=wInyVG_0wRrX_dRO9qbAzPhlXDseXapj2zQhsISw8gg,3233
245
246
  uk_bin_collection/uk_bin_collection/councils/RochdaleCouncil.py,sha256=UTSwSw515VehGn4xkjjRhUlzS4lDj4hgna6y-4VW3uM,2379
246
- uk_bin_collection/uk_bin_collection/councils/RochfordCouncil.py,sha256=rfhD66A9HfHL46ldF9sbxvV7fPaaoNxzIJbHjVT6A90,2621
247
+ uk_bin_collection/uk_bin_collection/councils/RochfordCouncil.py,sha256=a4sL2K3a0dAWeX74qW9bbsTC666ahNRz0rZg3fAn_C0,2623
247
248
  uk_bin_collection/uk_bin_collection/councils/RotherDistrictCouncil.py,sha256=-fdLvtik9ytfwXrrhwWdBxqQOMq2N1pvrIuvShhf8PU,3090
248
249
  uk_bin_collection/uk_bin_collection/councils/RotherhamCouncil.py,sha256=dfAqXtmbptHGZGGWkurjY9snaVm1aH5CGjhzdtoe4JM,2058
249
250
  uk_bin_collection/uk_bin_collection/councils/RoyalBoroughofGreenwich.py,sha256=AziuKhP6wKu_316MA4xXRN-ayDU6RSB21EfSWjmMqU8,3800
@@ -345,8 +346,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
345
346
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=QD4v4xpsEE0QheR_fGaNOIRMc2FatcUfKkkhAhseyVU,1159
346
347
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
347
348
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=Qb76X46V0UMZJwO8zMNPvnVY7jNa-bmTlrirDi1tuJA,4553
348
- uk_bin_collection-0.152.10.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
349
- uk_bin_collection-0.152.10.dist-info/METADATA,sha256=51DE3tDCHbfraq7wzD0wncD7biFXidumcQZfwgg3_Mk,26689
350
- uk_bin_collection-0.152.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
351
- uk_bin_collection-0.152.10.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
352
- uk_bin_collection-0.152.10.dist-info/RECORD,,
349
+ uk_bin_collection-0.152.11.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
350
+ uk_bin_collection-0.152.11.dist-info/METADATA,sha256=1aRDxnf77XU3b7Z4OQkJuVLt5H8ZzdF54MU39_w9fLU,26689
351
+ uk_bin_collection-0.152.11.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
352
+ uk_bin_collection-0.152.11.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
353
+ uk_bin_collection-0.152.11.dist-info/RECORD,,