uk_bin_collection 0.93.0__py3-none-any.whl → 0.94.0__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.
@@ -293,6 +293,14 @@
293
293
  "url": "https://service.croydon.gov.uk/wasteservices/w/webpage/bin-day-enter-address",
294
294
  "wiki_name": "Croydon Council"
295
295
  },
296
+ "DacorumBoroughCouncil": {
297
+ "house_number": "13",
298
+ "postcode": "HP3 9JY",
299
+ "skip_get_url": true,
300
+ "web_driver": "http://selenium:4444",
301
+ "url": "https://webapps.dacorum.gov.uk/bincollections/",
302
+ "wiki_name": "Dacorum Borough Council"
303
+ },
296
304
  "DartfordBoroughCouncil": {
297
305
  "uprn": "010094157511",
298
306
  "url": "https://windmz.dartford.gov.uk/ufs/WS_CHECK_COLLECTIONS.eb?UPRN=010094157511",
@@ -344,8 +352,8 @@
344
352
  "wiki_name": "East Cambridgeshire Council"
345
353
  },
346
354
  "EastDevonDC": {
347
- "url": "https://eastdevon.gov.uk/recycling-and-waste/recycling-and-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN=010090909915",
348
- "wiki_command_url_override": "https://eastdevon.gov.uk/recycling-and-waste/recycling-and-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN=XXXXXXXX",
355
+ "url": "https://eastdevon.gov.uk/recycling-and-waste/recycling-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN=010090909915",
356
+ "wiki_command_url_override": "https://eastdevon.gov.uk/recycling-waste/recycling-and-waste-information/when-is-my-bin-collected/future-collections-calendar/?UPRN=XXXXXXXX",
349
357
  "wiki_name": "East Devon District Council",
350
358
  "wiki_note": "Replace XXXXXXXX with UPRN."
351
359
  },
@@ -596,6 +604,12 @@
596
604
  "url": "https://www.hounslow.gov.uk/homepage/86/recycling_and_waste_collection_day_finder",
597
605
  "wiki_name": "London Borough Hounslow"
598
606
  },
607
+ "LondonBoroughLambeth": {
608
+ "skip_get_url": true,
609
+ "uprn": "100021881738",
610
+ "url": "https://wasteservice.lambeth.gov.uk/WhitespaceComms/GetServicesByUprn",
611
+ "wiki_name": "London Borough Lambeth"
612
+ },
599
613
  "LondonBoroughRedbridge": {
600
614
  "postcode": "IG2 6LQ",
601
615
  "uprn": "10023770353",
@@ -0,0 +1,102 @@
1
+ from bs4 import BeautifulSoup
2
+ from selenium.webdriver.common.by import By
3
+ from selenium.webdriver.support import expected_conditions as EC
4
+ from selenium.webdriver.support.wait import WebDriverWait
5
+
6
+ from uk_bin_collection.uk_bin_collection.common import *
7
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
8
+
9
+
10
+ # import the wonderful Beautiful Soup and the URL grabber
11
+ class CouncilClass(AbstractGetBinDataClass):
12
+ """
13
+ Concrete classes have to implement all abstract operations of the
14
+ base class. They can also override some operations with a default
15
+ implementation.
16
+ """
17
+
18
+ def parse_data(self, page: str, **kwargs) -> dict:
19
+ driver = None
20
+ try:
21
+ data = {"bins": []}
22
+ user_paon = kwargs.get("paon")
23
+ user_postcode = kwargs.get("postcode")
24
+ web_driver = kwargs.get("web_driver")
25
+ headless = kwargs.get("headless")
26
+ check_paon(user_paon)
27
+ check_postcode(user_postcode)
28
+
29
+ # Create Selenium webdriver
30
+ driver = create_webdriver(web_driver, headless, None, __name__)
31
+ driver.get("https://webapps.dacorum.gov.uk/bincollections/")
32
+
33
+ # Wait for the postcode field to appear then populate it
34
+ inputElement_postcode = WebDriverWait(driver, 30).until(
35
+ EC.presence_of_element_located((By.ID, "txtBxPCode"))
36
+ )
37
+ inputElement_postcode.send_keys(user_postcode)
38
+
39
+ # Click search button
40
+ findAddress = WebDriverWait(driver, 10).until(
41
+ EC.presence_of_element_located((By.ID, "btnFindAddr"))
42
+ )
43
+ findAddress.click()
44
+
45
+ # Wait for the 'Select address' dropdown to appear and select option matching the house name/number
46
+ WebDriverWait(driver, 10).until(
47
+ EC.element_to_be_clickable(
48
+ (
49
+ By.XPATH,
50
+ "//select[@id='lstBxAddrList']//option[contains(., '"
51
+ + user_paon
52
+ + "')]",
53
+ )
54
+ )
55
+ ).click()
56
+
57
+ # Click search button
58
+ findDates = WebDriverWait(driver, 10).until(
59
+ EC.presence_of_element_located((By.ID, "MainContent_btnGetSchedules"))
60
+ )
61
+ findDates.click()
62
+
63
+ # Wait for the collections table to appear
64
+ WebDriverWait(driver, 30).until(
65
+ EC.presence_of_element_located((By.ID, "lblSelectedAddr"))
66
+ )
67
+
68
+ soup = BeautifulSoup(driver.page_source, features="html.parser")
69
+ soup.prettify()
70
+
71
+ # Get collections div
72
+ BinCollectionSchedule = soup.find("div", {"id": "MainContent_updPnl"})
73
+
74
+ NextCollections = BinCollectionSchedule.find_all(
75
+ "div", {"style": " margin:5px;"}
76
+ )
77
+
78
+ for Collection in NextCollections:
79
+ BinType = Collection.find("strong").text.strip()
80
+ if BinType:
81
+ CollectionDate = datetime.strptime(
82
+ Collection.find_all("div", {"style": "display:table-cell;"})[1]
83
+ .get_text()
84
+ .strip(),
85
+ "%a, %d %b %Y",
86
+ )
87
+ dict_data = {
88
+ "type": BinType,
89
+ "collectionDate": CollectionDate.strftime("%d/%m/%Y"),
90
+ }
91
+ data["bins"].append(dict_data)
92
+
93
+ except Exception as e:
94
+ # Here you can log the exception if needed
95
+ print(f"An error occurred: {e}")
96
+ # Optionally, re-raise the exception if you want it to propagate
97
+ raise
98
+ finally:
99
+ # This block ensures that the driver is closed regardless of an exception
100
+ if driver:
101
+ driver.quit()
102
+ return data
@@ -0,0 +1,54 @@
1
+ import requests
2
+ from requests.structures import CaseInsensitiveDict
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
+ data = {"bins": []}
21
+
22
+ url = "https://wasteservice.lambeth.gov.uk/WhitespaceComms/GetServicesByUprn"
23
+
24
+ headers = CaseInsensitiveDict()
25
+ headers["Content-Type"] = "application/json"
26
+
27
+ body = {"uprn": user_uprn, "includeEventTypes": False, "includeFlags": True}
28
+ json_data = json.dumps(body)
29
+
30
+ res = requests.post(url, headers=headers, data=json_data)
31
+
32
+ if res.status_code != 200:
33
+ raise ConnectionRefusedError("Cannot connect to API!")
34
+
35
+ json_data = res.json()
36
+
37
+ if "SiteServices" in json_data:
38
+ SiteServices = json_data["SiteServices"]
39
+ for service in SiteServices:
40
+ if "NextCollectionDate" in service:
41
+ NextCollectionDate = service["NextCollectionDate"]
42
+ if NextCollectionDate:
43
+ Container = service["Container"]
44
+ if Container:
45
+ Bin_Type = Container["DisplayPhrase"]
46
+ dict_data = {
47
+ "type": Bin_Type,
48
+ "collectionDate": datetime.strptime(
49
+ NextCollectionDate, "%d/%m/%Y"
50
+ ).strftime(date_format),
51
+ }
52
+ data["bins"].append(dict_data)
53
+
54
+ return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.93.0
3
+ Version: 0.94.0
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -2,7 +2,7 @@ uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
2
2
  uk_bin_collection/tests/council_feature_input_parity.py,sha256=DO6Mk4ImYgM5ZCZ-cutwz5RoYYWZRLYx2tr6zIs_9Rc,3843
3
3
  uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
4
4
  uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=SJK-Vc737hrf03tssxxbeg_JIvAH-ddB8f6gU1LTbuQ,251
5
- uk_bin_collection/tests/input.json,sha256=plFsUdfPkEunhkM4EqRyhvWt5jDVvTgIxNaP5l7O-FI,62686
5
+ uk_bin_collection/tests/input.json,sha256=vimuJzI_t8_nzD9v1BC2vj3WbLLFpGtPhT10GjlBrAY,63198
6
6
  uk_bin_collection/tests/output.schema,sha256=ZwKQBwYyTDEM4G2hJwfLUVM-5v1vKRvRK9W9SS1sd18,1086
7
7
  uk_bin_collection/tests/step_defs/step_helpers/file_handler.py,sha256=Ygzi4V0S1MIHqbdstUlIqtRIwnynvhu4UtpweJ6-5N8,1474
8
8
  uk_bin_collection/tests/step_defs/test_validate_council.py,sha256=LrOSt_loA1Mw3vTqaO2LpaDMu7rYJy6k5Kr-EOBln7s,3424
@@ -51,6 +51,7 @@ uk_bin_collection/uk_bin_collection/councils/ConwyCountyBorough.py,sha256=el75qv
51
51
  uk_bin_collection/uk_bin_collection/councils/CornwallCouncil.py,sha256=W7_wWHLbE0cyE90GkNaZHmR7Lbd2Aq48A1hKMUNO-vg,2806
52
52
  uk_bin_collection/uk_bin_collection/councils/CrawleyBoroughCouncil.py,sha256=_BEKZAjlS5Ad5DjyxqAEFSLn8F-KYox0zmn4BXaAD6A,2367
53
53
  uk_bin_collection/uk_bin_collection/councils/CroydonCouncil.py,sha256=QJH27plySbbmoNcLNUXq-hUiFmZ5zBlRS5mzOJgWSK8,11594
54
+ uk_bin_collection/uk_bin_collection/councils/DacorumBoroughCouncil.py,sha256=Tm_6pvBPj-6qStbe6-02LXaoCOlnnDvVXAAocGVvf_E,3970
54
55
  uk_bin_collection/uk_bin_collection/councils/DartfordBoroughCouncil.py,sha256=SPirUUoweMwX5Txtsr0ocdcFtKxCQ9LhzTTJN20tM4w,1550
55
56
  uk_bin_collection/uk_bin_collection/councils/DerbyshireDalesDistrictCouncil.py,sha256=MQC1-jXezXczrxTcvPQvkpGgyyAbzSKlX38WsmftHak,4007
56
57
  uk_bin_collection/uk_bin_collection/councils/DoncasterCouncil.py,sha256=b7pxoToXu6dBBYXsXmlwfPXE8BjHxt0hjCOBNlNgvX8,3118
@@ -93,6 +94,7 @@ uk_bin_collection/uk_bin_collection/councils/LeedsCityCouncil.py,sha256=iSZApZ9o
93
94
  uk_bin_collection/uk_bin_collection/councils/LisburnCastlereaghCityCouncil.py,sha256=vSOzdEwp9ZeUhed7E3eVv9ReD-2XgbSkpyAbVnfc-Gk,3309
94
95
  uk_bin_collection/uk_bin_collection/councils/LiverpoolCityCouncil.py,sha256=n17OqZrCGrPrnxGUfHc-RGkb4oJ9Bx6uUWiLdzxfQlY,2587
95
96
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughHounslow.py,sha256=UOeiOxGMvVMm2UFaqjmQpm7vxzqJNSSN8LM9lAUjs2c,3021
97
+ uk_bin_collection/uk_bin_collection/councils/LondonBoroughLambeth.py,sha256=r9D5lHe5kIRStCd5lRIax16yhb4KTFzzfYEFv1bacWw,2009
96
98
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughRedbridge.py,sha256=A_6Sis5hsF53Th04KeadHRasGbpAm6aoaWJ6X8eC4Y8,6604
97
99
  uk_bin_collection/uk_bin_collection/councils/MaldonDistrictCouncil.py,sha256=PMVt2XFggttPmbWyrBrHJ-W6R_6-0ux1BkY1kj1IKzg,1997
98
100
  uk_bin_collection/uk_bin_collection/councils/MalvernHillsDC.py,sha256=iQG0EkX2npBicvsGKQRYyBGSBvKVUbKvUvvwrC9xV1A,2100
@@ -195,8 +197,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
195
197
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
196
198
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
197
199
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
198
- uk_bin_collection-0.93.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
199
- uk_bin_collection-0.93.0.dist-info/METADATA,sha256=7kwdZTwvv9O_E9-bwtzmciKYKb_PX0QrVo_Zhwebl7w,16843
200
- uk_bin_collection-0.93.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
201
- uk_bin_collection-0.93.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
202
- uk_bin_collection-0.93.0.dist-info/RECORD,,
200
+ uk_bin_collection-0.94.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
201
+ uk_bin_collection-0.94.0.dist-info/METADATA,sha256=E6gDNbSQbwplbWVHaTuOwLPKE3XsRLRIFQRMLCTn7QI,16843
202
+ uk_bin_collection-0.94.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
203
+ uk_bin_collection-0.94.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
204
+ uk_bin_collection-0.94.0.dist-info/RECORD,,