uk_bin_collection 0.127.3__py3-none-any.whl → 0.127.4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1030,6 +1030,13 @@
1030
1030
  "wiki_name": "London Borough Ealing",
1031
1031
  "wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1032
1032
  },
1033
+ "LondonBoroughOfRichmondUponThames": {
1034
+ "house_number": "March Road",
1035
+ "skip_get_url": true,
1036
+ "url": "https://www.richmond.gov.uk/services/waste_and_recycling/collection_days/",
1037
+ "wiki_name": "London Borough Of Richmond Upon Thames",
1038
+ "wiki_note": "Pass the name of the street ONLY in the house number parameter, unfortunately post code's are not allowed. "
1039
+ },
1033
1040
  "LondonBoroughHarrow": {
1034
1041
  "url": "https://www.harrow.gov.uk",
1035
1042
  "wiki_command_url_override": "https://www.harrow.gov.uk",
@@ -0,0 +1,98 @@
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from datetime import datetime
4
+ from selenium.webdriver.support.wait import WebDriverWait
5
+ from selenium.webdriver.common.keys import Keys
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
+ class CouncilClass(AbstractGetBinDataClass):
11
+
12
+ def parse_data(self, page: str, **kwargs) -> dict:
13
+ print(f"Arguments are f{kwargs}")
14
+ driver = None
15
+ try:
16
+ page = kwargs["url"]
17
+ street_name = kwargs.get("paon")
18
+ web_driver = kwargs.get("web_driver")
19
+ headless = kwargs.get("headless")
20
+
21
+ driver = create_webdriver(web_driver, headless, None, __name__)
22
+ driver.get(page)
23
+
24
+ wait = WebDriverWait(driver, 60)
25
+
26
+ self.dismiss_cookie_banner(wait)
27
+ self.input_street_name(street_name, wait)
28
+ self.submit(wait)
29
+ bin_types, collection_days = self.get_bins(driver)
30
+ bindata = self.get_collection_days(bin_types, collection_days)
31
+
32
+ print(bindata)
33
+
34
+ except Exception as e:
35
+ # Here you can log the exception if needed
36
+ print(f"An error occurred: {e}")
37
+ # Optionally, re-raise the exception if you want it to propagate
38
+ raise
39
+ finally:
40
+ # This block ensures that the driver is closed regardless of an exception
41
+ if driver:
42
+ driver.quit()
43
+ return bindata
44
+
45
+ def get_collection_days(self, bin_types, collection_days):
46
+ bindata = {"bins": []}
47
+ WEEKLY_COLLECTION = 0
48
+ GARDEN_COLLECTION = 1
49
+
50
+ for index, bin_type in enumerate(bin_types):
51
+ # currently only handled weekly and garden collection, special collections like Christmas Day need to be added
52
+ if index == WEEKLY_COLLECTION:
53
+ next_collection_date = get_next_day_of_week(collection_days[index].text.strip(), date_format)
54
+ elif index == GARDEN_COLLECTION:
55
+ split_date_part = collection_days[index].text.split("More dates")[0]
56
+ next_collection_date = datetime.strptime(split_date_part.strip(), "%d %B %Y").strftime(date_format)
57
+ else:
58
+ next_collection_date = datetime.strptime(collection_days[index].text.strip(), "%d %B %Y").strftime(date_format)
59
+
60
+ dict_data = {
61
+ "type": bin_type.text.strip(),
62
+ "collectionDate": next_collection_date,
63
+ }
64
+ bindata["bins"].append(dict_data)
65
+ return bindata
66
+
67
+ def get_bins(self, driver):
68
+ table = driver.find_element(By.XPATH, ".//div[@id='maincontent']//table")
69
+ table_rows = table.find_elements(by=By.TAG_NAME, value="tr")
70
+ headerRow = table_rows[0]
71
+ table_info_row = table_rows[1]
72
+ bin_types = headerRow.find_elements(by=By.TAG_NAME, value="th")[2:]
73
+ collection_days = table_info_row.find_elements(by=By.TAG_NAME, value="td")[2:]
74
+ return bin_types, collection_days
75
+
76
+ def submit(self, wait):
77
+ main_content_submit_button = wait.until(
78
+ EC.element_to_be_clickable(
79
+ (By.XPATH, ".//div[@id='maincontent']//input[@type='submit']")
80
+ )
81
+ )
82
+ main_content_submit_button.send_keys(Keys.ENTER)
83
+
84
+ def input_street_name(self, street_name, wait):
85
+ input_element_postcodesearch = wait.until(
86
+ EC.visibility_of_element_located(
87
+ (By.ID, "Street")
88
+ )
89
+ )
90
+ input_element_postcodesearch.send_keys(street_name)
91
+
92
+ def dismiss_cookie_banner(self, wait):
93
+ cookie_banner = wait.until(
94
+ EC.visibility_of_element_located(
95
+ (By.ID, "ccc-dismiss-button")
96
+ )
97
+ )
98
+ cookie_banner.send_keys(Keys.ENTER)
@@ -125,10 +125,10 @@ class CouncilClass(AbstractGetBinDataClass):
125
125
  )
126
126
 
127
127
  # Garden waste
128
- garden_waste = soup.find("span", class_="CTID-17-_ eb-17-textControl")
128
+ garden_waste = soup.find("div", class_="eb-2HIpCnWC-Override-EditorInput")
129
129
  if garden_waste:
130
130
  match = re.search(
131
- r"next collection is\s+(\d{2}/\d{2}/\d{4})", garden_waste.text
131
+ r"(\d{2}/\d{2}/\d{4})", garden_waste.text
132
132
  )
133
133
  if match:
134
134
  bins.append(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.127.3
3
+ Version: 0.127.4
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=P1EVRcGMASZCNVTAfhiQntWctYAdxa8nBytUeHLB0vY,114379
5
+ uk_bin_collection/tests/input.json,sha256=TdxYXHlJlV1eO1flmo8pqn3beIagaugbpa6yvcmE_9E,114783
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=VZ0a81sioJULD7syAYHjvK_-nT_Rd36tUyzPetSA0gk,3475
@@ -150,6 +150,7 @@ uk_bin_collection/uk_bin_collection/councils/LondonBoroughHavering.py,sha256=6DN
150
150
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughHounslow.py,sha256=UOeiOxGMvVMm2UFaqjmQpm7vxzqJNSSN8LM9lAUjs2c,3021
151
151
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughLambeth.py,sha256=r9D5lHe5kIRStCd5lRIax16yhb4KTFzzfYEFv1bacWw,2009
152
152
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughLewisham.py,sha256=d8rlJDTbY3nj-Zjg6iwvwfe-X13Gq86DGGW6QkQAUW0,5310
153
+ uk_bin_collection/uk_bin_collection/councils/LondonBoroughOfRichmondUponThames.py,sha256=F5G_Xu-nilCA72Qbm9N87q77yYZMzyXhiuJaB1tjFFs,3933
153
154
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughRedbridge.py,sha256=A_6Sis5hsF53Th04KeadHRasGbpAm6aoaWJ6X8eC4Y8,6604
154
155
  uk_bin_collection/uk_bin_collection/councils/LondonBoroughSutton.py,sha256=T0gCjpBQ9k3uNNIiJGphNiSXeh2n6bohflg9RwbL3NA,2565
155
156
  uk_bin_collection/uk_bin_collection/councils/LutonBoroughCouncil.py,sha256=vScUi_R8FnBddii2_zLlZBLxuh85mKmCm8nKW3zxky0,2758
@@ -168,7 +169,7 @@ uk_bin_collection/uk_bin_collection/councils/MoleValleyDistrictCouncil.py,sha256
168
169
  uk_bin_collection/uk_bin_collection/councils/MonmouthshireCountyCouncil.py,sha256=V3R98D3DtCPZK3RNCg8yR2ddoUz_tOzl2YTgWfjdPX0,2468
169
170
  uk_bin_collection/uk_bin_collection/councils/MorayCouncil.py,sha256=jsHCQ_aV_bG0GPfF7h6g5TP84sroplYC5k2M6iEKiTw,2265
170
171
  uk_bin_collection/uk_bin_collection/councils/NeathPortTalbotCouncil.py,sha256=ychYR2nsyk2UIb8tjWaKrLUT4hxSsHN558l3RqZ0mjw,5635
171
- uk_bin_collection/uk_bin_collection/councils/NewForestCouncil.py,sha256=ylTn9KmWITtaO9_Z8kJCN2w2ALfhrfGt3SeJ78lgw7M,5391
172
+ uk_bin_collection/uk_bin_collection/councils/NewForestCouncil.py,sha256=LSQu1djVkbp4ous3DuOr9VWg4k9sFyBrQ2ZaJHY5FbA,5374
172
173
  uk_bin_collection/uk_bin_collection/councils/NewarkAndSherwoodDC.py,sha256=lAleYfCGUWCKOi7Ye_cjgfpI3pWwTcFctlYmh0hjebM,2140
173
174
  uk_bin_collection/uk_bin_collection/councils/NewcastleCityCouncil.py,sha256=eJMX10CG9QO7FRhHSmUDL-jO_44qoK3_1ztNTAXhkbw,2085
174
175
  uk_bin_collection/uk_bin_collection/councils/NewcastleUnderLymeCouncil.py,sha256=t150wPtF2eEFYNTVj2EnhXt6JJJRiEX8976bh9JBXlg,2328
@@ -299,8 +300,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
299
300
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
300
301
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
301
302
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
302
- uk_bin_collection-0.127.3.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
303
- uk_bin_collection-0.127.3.dist-info/METADATA,sha256=N5s90XpaFpVWjIAj1fQVSLB2QnHms0H6nZqXyQNsBww,19549
304
- uk_bin_collection-0.127.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
305
- uk_bin_collection-0.127.3.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
306
- uk_bin_collection-0.127.3.dist-info/RECORD,,
303
+ uk_bin_collection-0.127.4.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
304
+ uk_bin_collection-0.127.4.dist-info/METADATA,sha256=PEi9YKlMqAEGH-taK-nNRm9M5PxrewNMTbaireIyjhE,19549
305
+ uk_bin_collection-0.127.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
306
+ uk_bin_collection-0.127.4.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
307
+ uk_bin_collection-0.127.4.dist-info/RECORD,,