uk_bin_collection 0.148.2__py3-none-any.whl → 0.148.3__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/HyndburnBoroughCouncil.py +143 -0
- {uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/RECORD +7 -6
- {uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/entry_points.txt +0 -0
@@ -1196,6 +1196,15 @@
|
|
1196
1196
|
"wiki_name": "Huntingdon District Council",
|
1197
1197
|
"wiki_note": "Replace XXXXXXXX with your UPRN."
|
1198
1198
|
},
|
1199
|
+
"HyndburnBoroughCouncil": {
|
1200
|
+
"postcode": "BB1 4DJ",
|
1201
|
+
"LAD24CD": "E07000120",
|
1202
|
+
"uprn": "100010448773",
|
1203
|
+
"url": "https://iapp.itouchvision.com/iappcollectionday/collection-day/?uuid=FEBA68993831481FD81B2E605364D00A8DC017A4",
|
1204
|
+
"web_driver": "http://selenium:4444",
|
1205
|
+
"wiki_name": "Hyndburn",
|
1206
|
+
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search). This parser requires a Selenium webdriver."
|
1207
|
+
},
|
1199
1208
|
"IpswichBoroughCouncil": {
|
1200
1209
|
"house_number": "Siloam Place",
|
1201
1210
|
"url": "https://app.ipswich.gov.uk/bin-collection/",
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
from bs4 import BeautifulSoup
|
4
|
+
from selenium.webdriver.common.by import By
|
5
|
+
from selenium.webdriver.common.keys import Keys
|
6
|
+
from selenium.webdriver.support import expected_conditions as EC
|
7
|
+
from selenium.webdriver.support.ui import Select, WebDriverWait
|
8
|
+
|
9
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
10
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
11
|
+
|
12
|
+
|
13
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
14
|
+
class CouncilClass(AbstractGetBinDataClass):
|
15
|
+
"""
|
16
|
+
Concrete classes have to implement all abstract operations of the
|
17
|
+
base class. They can also override some operations with a default
|
18
|
+
implementation.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
22
|
+
driver = None
|
23
|
+
try:
|
24
|
+
user_postcode = kwargs.get("postcode")
|
25
|
+
if not user_postcode:
|
26
|
+
raise ValueError("No postcode provided.")
|
27
|
+
check_postcode(user_postcode)
|
28
|
+
|
29
|
+
user_uprn = kwargs.get("uprn")
|
30
|
+
headless = kwargs.get("headless")
|
31
|
+
web_driver = kwargs.get("web_driver")
|
32
|
+
driver = create_webdriver(web_driver, headless, None, __name__)
|
33
|
+
page = "https://iapp.itouchvision.com/iappcollectionday/collection-day/?uuid=FEBA68993831481FD81B2E605364D00A8DC017A4"
|
34
|
+
|
35
|
+
driver.get(page)
|
36
|
+
|
37
|
+
postcode_input = WebDriverWait(driver, 60).until(
|
38
|
+
EC.presence_of_element_located((By.ID, "postcodeSearch"))
|
39
|
+
)
|
40
|
+
|
41
|
+
postcode_input.send_keys(user_postcode)
|
42
|
+
postcode_input.send_keys(Keys.TAB + Keys.RETURN)
|
43
|
+
|
44
|
+
# Wait for address box to be visible
|
45
|
+
select_address_input = WebDriverWait(driver, 10).until(
|
46
|
+
EC.presence_of_element_located(
|
47
|
+
(
|
48
|
+
By.XPATH,
|
49
|
+
'//*[@id="addressSelect"]',
|
50
|
+
)
|
51
|
+
)
|
52
|
+
)
|
53
|
+
|
54
|
+
# Select address based on UPRN
|
55
|
+
select = Select(select_address_input)
|
56
|
+
if not user_uprn:
|
57
|
+
raise ValueError("No UPRN provided")
|
58
|
+
|
59
|
+
try:
|
60
|
+
select.select_by_value(str(user_uprn))
|
61
|
+
except Exception as e:
|
62
|
+
raise ValueError(f"Could not find address with UPRN: {user_uprn}")
|
63
|
+
|
64
|
+
# Wait for address selection to complete
|
65
|
+
time.sleep(5)
|
66
|
+
|
67
|
+
# Wait for the main container with bin collection data
|
68
|
+
WebDriverWait(driver, 60).until(
|
69
|
+
EC.presence_of_element_located(
|
70
|
+
(By.CSS_SELECTOR, "div.ant-row.d-flex.justify-content-between")
|
71
|
+
)
|
72
|
+
)
|
73
|
+
|
74
|
+
# Verify bin collection data is loaded by checking for specific elements
|
75
|
+
WebDriverWait(driver, 60).until(
|
76
|
+
EC.presence_of_all_elements_located(
|
77
|
+
(By.CSS_SELECTOR, "div.ant-col h3.text-white")
|
78
|
+
)
|
79
|
+
)
|
80
|
+
|
81
|
+
# Remove unnecessary waits and div ID check
|
82
|
+
time.sleep(2) # Short wait for any final rendering
|
83
|
+
|
84
|
+
# Continue with BeautifulSoup parsing
|
85
|
+
soup = BeautifulSoup(driver.page_source, "html.parser")
|
86
|
+
bin_data = {"bins": []}
|
87
|
+
|
88
|
+
# Find all bin collection divs
|
89
|
+
bin_divs = soup.find_all("div", class_="ant-col")
|
90
|
+
|
91
|
+
for bin_div in bin_divs:
|
92
|
+
# Find bin type from h3
|
93
|
+
bin_type_elem = bin_div.find("h3", class_="text-white")
|
94
|
+
if not bin_type_elem:
|
95
|
+
continue
|
96
|
+
|
97
|
+
bin_type = bin_type_elem.text.strip()
|
98
|
+
|
99
|
+
# Find collection date
|
100
|
+
date_elem = bin_div.find("div", class_="text-white fw-bold")
|
101
|
+
if not date_elem:
|
102
|
+
continue
|
103
|
+
|
104
|
+
collection_date_string = date_elem.text.strip()
|
105
|
+
|
106
|
+
# Handle date formatting
|
107
|
+
current_date = datetime.now()
|
108
|
+
# Parse the date string (e.g. "Monday 28 April")
|
109
|
+
try:
|
110
|
+
parsed_date = datetime.strptime(
|
111
|
+
collection_date_string + f" {current_date.year}", "%A %d %B %Y"
|
112
|
+
)
|
113
|
+
|
114
|
+
# Check if the parsed date is in the past
|
115
|
+
if parsed_date.date() < current_date.date():
|
116
|
+
# If so, set the year to the next year
|
117
|
+
parsed_date = parsed_date.replace(year=current_date.year + 1)
|
118
|
+
|
119
|
+
formatted_date = parsed_date.strftime("%d/%m/%Y")
|
120
|
+
contains_date(formatted_date)
|
121
|
+
|
122
|
+
bin_info = {"type": bin_type, "collectionDate": formatted_date}
|
123
|
+
bin_data["bins"].append(bin_info)
|
124
|
+
except ValueError as e:
|
125
|
+
print(f"Error parsing date {collection_date_string}: {e}")
|
126
|
+
continue
|
127
|
+
|
128
|
+
if not bin_data["bins"]:
|
129
|
+
raise ValueError("No collection data found")
|
130
|
+
|
131
|
+
print(bin_data)
|
132
|
+
|
133
|
+
return bin_data
|
134
|
+
|
135
|
+
except Exception as e:
|
136
|
+
# Here you can log the exception if needed
|
137
|
+
print(f"An error occurred: {e}")
|
138
|
+
# Optionally, re-raise the exception if you want it to propagate
|
139
|
+
raise
|
140
|
+
finally:
|
141
|
+
# This block ensures that the driver is closed regardless of an exception
|
142
|
+
if driver:
|
143
|
+
driver.quit()
|
@@ -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=
|
10
|
+
uk_bin_collection/tests/input.json,sha256=p_PfBWYOP3jsRCG0h9UTa_MlAzcrqMKAOy5P2N9EfwM,135010
|
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
|
@@ -155,6 +155,7 @@ uk_bin_collection/uk_bin_collection/councils/HinckleyandBosworthBoroughCouncil.p
|
|
155
155
|
uk_bin_collection/uk_bin_collection/councils/HorshamDistrictCouncil.py,sha256=U8WelJiHivT7CS3meUVcLURWOLRKes1pKZ81tcqKarM,4446
|
156
156
|
uk_bin_collection/uk_bin_collection/councils/HullCityCouncil.py,sha256=UHcesBoctFVcXDYuwfag43KbcJcopkEDzJ-54NxtK0Q,1851
|
157
157
|
uk_bin_collection/uk_bin_collection/councils/HuntingdonDistrictCouncil.py,sha256=dGyhhG6HRjQ2SPeiRwUPTGlk9dPIslagV2k0GjEOn1s,1587
|
158
|
+
uk_bin_collection/uk_bin_collection/councils/HyndburnBoroughCouncil.py,sha256=_lJ__EMcUBbE4QZvH-c1nCGeKxZTn5hhcpjVAYBbJZc,5403
|
158
159
|
uk_bin_collection/uk_bin_collection/councils/IpswichBoroughCouncil.py,sha256=57lmDl_FprG68gUhKQYpOa1M2pudyb1utfoMhUXNwzs,2802
|
159
160
|
uk_bin_collection/uk_bin_collection/councils/IslingtonCouncil.py,sha256=xavzL6ZIU9DG8Xro3vN0CEnYmNU31OGnOvnq78wgpQc,1258
|
160
161
|
uk_bin_collection/uk_bin_collection/councils/KingsLynnandWestNorfolkBC.py,sha256=Shj18R-7NW4ivqJJFVJOLmf-EeN6hXP2Of30oI-SeAQ,1932
|
@@ -336,8 +337,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
336
337
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=QD4v4xpsEE0QheR_fGaNOIRMc2FatcUfKkkhAhseyVU,1159
|
337
338
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
338
339
|
uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
|
339
|
-
uk_bin_collection-0.148.
|
340
|
-
uk_bin_collection-0.148.
|
341
|
-
uk_bin_collection-0.148.
|
342
|
-
uk_bin_collection-0.148.
|
343
|
-
uk_bin_collection-0.148.
|
340
|
+
uk_bin_collection-0.148.3.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
341
|
+
uk_bin_collection-0.148.3.dist-info/METADATA,sha256=GnD4UvGYQsS6G8rNA5Idbr7vemGqQYZZvMdRWWqjh_o,20914
|
342
|
+
uk_bin_collection-0.148.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
343
|
+
uk_bin_collection-0.148.3.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
344
|
+
uk_bin_collection-0.148.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.148.2.dist-info → uk_bin_collection-0.148.3.dist-info}/entry_points.txt
RENAMED
File without changes
|