uk_bin_collection 0.93.0__py3-none-any.whl → 0.95.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
  },
@@ -590,12 +598,24 @@
590
598
  "wiki_name": "Liverpool City Council",
591
599
  "wiki_note": "Replace XXXXXXXX with your property's UPRN."
592
600
  },
601
+ "LondonBoroughEaling": {
602
+ "skip_get_url": true,
603
+ "uprn": "12081498",
604
+ "url": "https://www.ealing.gov.uk/site/custom_scripts/WasteCollectionWS/home/FindCollection",
605
+ "wiki_name": "London Borough Ealing"
606
+ },
593
607
  "LondonBoroughHounslow": {
594
608
  "skip_get_url": true,
595
609
  "uprn": "100021577765",
596
610
  "url": "https://www.hounslow.gov.uk/homepage/86/recycling_and_waste_collection_day_finder",
597
611
  "wiki_name": "London Borough Hounslow"
598
612
  },
613
+ "LondonBoroughLambeth": {
614
+ "skip_get_url": true,
615
+ "uprn": "100021881738",
616
+ "url": "https://wasteservice.lambeth.gov.uk/WhitespaceComms/GetServicesByUprn",
617
+ "wiki_name": "London Borough Lambeth"
618
+ },
599
619
  "LondonBoroughRedbridge": {
600
620
  "postcode": "IG2 6LQ",
601
621
  "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,50 @@
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://www.ealing.gov.uk/site/custom_scripts/WasteCollectionWS/home/FindCollection"
23
+
24
+ headers = CaseInsensitiveDict()
25
+ headers["Content-Type"] = "application/json"
26
+
27
+ body = {"uprn": user_uprn}
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 "param2" in json_data:
38
+ param2 = json_data["param2"]
39
+ for service in param2:
40
+ Bin_Type = service["Service"]
41
+ NextCollectionDate = service["collectionDateString"]
42
+ dict_data = {
43
+ "type": Bin_Type,
44
+ "collectionDate": datetime.strptime(
45
+ NextCollectionDate, "%d/%m/%Y"
46
+ ).strftime(date_format),
47
+ }
48
+ data["bins"].append(dict_data)
49
+
50
+ 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.95.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=9YyrjZ9mH77wJ1qkoOPD9p4eiFEF0_J6xE7phELNeIo,63439
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
@@ -92,7 +93,9 @@ uk_bin_collection/uk_bin_collection/councils/LancasterCityCouncil.py,sha256=FmHT
92
93
  uk_bin_collection/uk_bin_collection/councils/LeedsCityCouncil.py,sha256=iSZApZ9oSfSatQ6dAxmykSfti91jGuY6n2BwEkVMOiU,5144
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
96
+ uk_bin_collection/uk_bin_collection/councils/LondonBoroughEaling.py,sha256=QDx2Izr-6hUSFMi4UWqsgo3p6U8aRZ9d_Cu9cBSp2rY,1653
95
97
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughHounslow.py,sha256=UOeiOxGMvVMm2UFaqjmQpm7vxzqJNSSN8LM9lAUjs2c,3021
98
+ uk_bin_collection/uk_bin_collection/councils/LondonBoroughLambeth.py,sha256=r9D5lHe5kIRStCd5lRIax16yhb4KTFzzfYEFv1bacWw,2009
96
99
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughRedbridge.py,sha256=A_6Sis5hsF53Th04KeadHRasGbpAm6aoaWJ6X8eC4Y8,6604
97
100
  uk_bin_collection/uk_bin_collection/councils/MaldonDistrictCouncil.py,sha256=PMVt2XFggttPmbWyrBrHJ-W6R_6-0ux1BkY1kj1IKzg,1997
98
101
  uk_bin_collection/uk_bin_collection/councils/MalvernHillsDC.py,sha256=iQG0EkX2npBicvsGKQRYyBGSBvKVUbKvUvvwrC9xV1A,2100
@@ -195,8 +198,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
195
198
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
196
199
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
197
200
  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,,
201
+ uk_bin_collection-0.95.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
202
+ uk_bin_collection-0.95.0.dist-info/METADATA,sha256=Zw1i8zJ0E2Bhgn45ExUd1NCU8D8pgGWsbfShi88vm2Q,16843
203
+ uk_bin_collection-0.95.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
204
+ uk_bin_collection-0.95.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
205
+ uk_bin_collection-0.95.0.dist-info/RECORD,,