uk_bin_collection 0.89.1__py3-none-any.whl → 0.91.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.
- uk_bin_collection/tests/input.json +9 -0
- uk_bin_collection/uk_bin_collection/councils/EastRenfrewshireCouncil.py +117 -0
- {uk_bin_collection-0.89.1.dist-info → uk_bin_collection-0.91.0.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.89.1.dist-info → uk_bin_collection-0.91.0.dist-info}/RECORD +7 -6
- {uk_bin_collection-0.89.1.dist-info → uk_bin_collection-0.91.0.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.89.1.dist-info → uk_bin_collection-0.91.0.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.89.1.dist-info → uk_bin_collection-0.91.0.dist-info}/entry_points.txt +0 -0
@@ -341,6 +341,15 @@
|
|
341
341
|
"wiki_name": "East Lindsey District Council",
|
342
342
|
"wiki_note": "Pass the house name/number in the house number parameter, wrapped in double quotes"
|
343
343
|
},
|
344
|
+
"EastRenfrewshireCouncil": {
|
345
|
+
"house_number": "23",
|
346
|
+
"postcode": "G46 6RG",
|
347
|
+
"skip_get_url": true,
|
348
|
+
"url": "https://eastrenfrewshire.gov.uk/",
|
349
|
+
"web_driver": "http://selenium:4444",
|
350
|
+
"wiki_name": "East Renfrewshire Council",
|
351
|
+
"wiki_note": "Pass the house name/number in the house number parameter, wrapped in double quotes"
|
352
|
+
},
|
344
353
|
"EastRidingCouncil": {
|
345
354
|
"house_number": "14 THE LEASES BEVERLEY HU17 8LG",
|
346
355
|
"postcode": "HU17 8LG",
|
@@ -0,0 +1,117 @@
|
|
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(
|
32
|
+
"https://eastrenfrewshire.gov.uk/article/1145/Bin-collection-days"
|
33
|
+
)
|
34
|
+
|
35
|
+
# Wait for the postcode field to appear then populate it
|
36
|
+
inputElement_postcode = WebDriverWait(driver, 30).until(
|
37
|
+
EC.presence_of_element_located(
|
38
|
+
(By.ID, "RESIDUALWASTEV2_PAGE1_POSTCODE")
|
39
|
+
)
|
40
|
+
)
|
41
|
+
inputElement_postcode.send_keys(user_postcode)
|
42
|
+
|
43
|
+
# Click search button
|
44
|
+
findAddress = WebDriverWait(driver, 10).until(
|
45
|
+
EC.presence_of_element_located(
|
46
|
+
(By.ID, "RESIDUALWASTEV2_PAGE1_FIELD199_NEXT")
|
47
|
+
)
|
48
|
+
)
|
49
|
+
findAddress.click()
|
50
|
+
|
51
|
+
# Wait for the 'Select address' dropdown to appear and select option matching the house name/number
|
52
|
+
WebDriverWait(driver, 10).until(
|
53
|
+
EC.element_to_be_clickable(
|
54
|
+
(
|
55
|
+
By.XPATH,
|
56
|
+
"//select[@id='RESIDUALWASTEV2_PAGE2_UPRN']//option[contains(., '"
|
57
|
+
+ user_paon
|
58
|
+
+ "')]",
|
59
|
+
)
|
60
|
+
)
|
61
|
+
).click()
|
62
|
+
|
63
|
+
# Click search button
|
64
|
+
findDates = WebDriverWait(driver, 10).until(
|
65
|
+
EC.presence_of_element_located(
|
66
|
+
(By.ID, "RESIDUALWASTEV2_PAGE2_FIELD206_NEXT")
|
67
|
+
)
|
68
|
+
)
|
69
|
+
findDates.click()
|
70
|
+
|
71
|
+
# Wait for the collections table to appear
|
72
|
+
WebDriverWait(driver, 10).until(
|
73
|
+
EC.presence_of_element_located(
|
74
|
+
(By.ID, "RESIDUALWASTEV2_COLLECTIONDATES_DISPLAYBINCOLLECTIONINFO")
|
75
|
+
)
|
76
|
+
)
|
77
|
+
|
78
|
+
soup = BeautifulSoup(driver.page_source, features="html.parser")
|
79
|
+
soup.prettify()
|
80
|
+
|
81
|
+
# Get collections div
|
82
|
+
next_collection_div = soup.find("div", {"id": "yourNextCollection"})
|
83
|
+
|
84
|
+
# Get next collection date
|
85
|
+
next_collection_date = datetime.strptime(
|
86
|
+
next_collection_div.find("span", {"class": "dueDate"})
|
87
|
+
.get_text()
|
88
|
+
.strip(),
|
89
|
+
"%d/%m/%Y",
|
90
|
+
)
|
91
|
+
|
92
|
+
# Get next collection bins
|
93
|
+
next_collection_bin = next_collection_div.findAll(
|
94
|
+
"span", {"class": "binColour"}
|
95
|
+
)
|
96
|
+
|
97
|
+
# Format results
|
98
|
+
for row in next_collection_bin:
|
99
|
+
dict_data = {
|
100
|
+
"type": row.get_text().strip(),
|
101
|
+
"collectionDate": next_collection_date.strftime("%d/%m/%Y"),
|
102
|
+
}
|
103
|
+
data["bins"].append(dict_data)
|
104
|
+
|
105
|
+
data["bins"].sort(
|
106
|
+
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
|
107
|
+
)
|
108
|
+
except Exception as e:
|
109
|
+
# Here you can log the exception if needed
|
110
|
+
print(f"An error occurred: {e}")
|
111
|
+
# Optionally, re-raise the exception if you want it to propagate
|
112
|
+
raise
|
113
|
+
finally:
|
114
|
+
# This block ensures that the driver is closed regardless of an exception
|
115
|
+
if driver:
|
116
|
+
driver.quit()
|
117
|
+
return data
|
@@ -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=
|
5
|
+
uk_bin_collection/tests/input.json,sha256=wvkZlpCUMF9dJl3nl0Uy1G8OwwInlIBr5s45YHa6HhY,61255
|
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
|
@@ -59,6 +59,7 @@ uk_bin_collection/uk_bin_collection/councils/EalingCouncil.py,sha256=UhNXGi-_6NY
|
|
59
59
|
uk_bin_collection/uk_bin_collection/councils/EastCambridgeshireCouncil.py,sha256=aYUVE5QqTxdj8FHhCB4EiFVDJahWJD9Pq0d1upBEvXg,1501
|
60
60
|
uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py,sha256=U0VwSNIldMv5nUoiXtFgjbE0m6Kb-8W2WZQGVCNF_WI,3261
|
61
61
|
uk_bin_collection/uk_bin_collection/councils/EastLindseyDistrictCouncil.py,sha256=o_HPSFhb2ybmwv32_7T7CO1f2mGDkYCNPfaM5xz6bUI,4356
|
62
|
+
uk_bin_collection/uk_bin_collection/councils/EastRenfrewshireCouncil.py,sha256=5giegMCKQ2JhVDR5M4mevVxIdhZtSW7kbuuoSkj3EGk,4361
|
62
63
|
uk_bin_collection/uk_bin_collection/councils/EastRidingCouncil.py,sha256=CsYdkmL-8Ty-Kz7uNdlnJnhiDMgOPah_swYgSKbaFqA,5218
|
63
64
|
uk_bin_collection/uk_bin_collection/councils/EastSuffolkCouncil.py,sha256=qQ0oOfGd0sWcczse_B22YoeL9uj3og8v3UJLt_Sx29c,4353
|
64
65
|
uk_bin_collection/uk_bin_collection/councils/EastleighBoroughCouncil.py,sha256=V4Vso4DvawFiezKlmXbTlJEK9Sjhz9nA8WeYjwtO2e4,2310
|
@@ -190,8 +191,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
190
191
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=4s9ODGPAwPqwXc8SrTX5Wlfmizs3_58iXUtHc4Ir86o,1162
|
191
192
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
192
193
|
uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
|
193
|
-
uk_bin_collection-0.
|
194
|
-
uk_bin_collection-0.
|
195
|
-
uk_bin_collection-0.
|
196
|
-
uk_bin_collection-0.
|
197
|
-
uk_bin_collection-0.
|
194
|
+
uk_bin_collection-0.91.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
195
|
+
uk_bin_collection-0.91.0.dist-info/METADATA,sha256=x1y0i9KtwbqcyFdM80KVb6dWUyt7MLPsLo83Xq63KS0,16642
|
196
|
+
uk_bin_collection-0.91.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
197
|
+
uk_bin_collection-0.91.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
198
|
+
uk_bin_collection-0.91.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|