uk_bin_collection 0.148.0__py3-none-any.whl → 0.148.1__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/uk_bin_collection/councils/CheltenhamBoroughCouncil.py +71 -26
- uk_bin_collection/uk_bin_collection/councils/EastLindseyDistrictCouncil.py +4 -4
- uk_bin_collection/uk_bin_collection/councils/HarrogateBoroughCouncil.py +1 -1
- {uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/RECORD +8 -8
- {uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
# import re
|
2
|
-
|
3
1
|
import requests
|
2
|
+
from bs4 import BeautifulSoup
|
3
|
+
from dateutil.parser import parse
|
4
4
|
|
5
5
|
from uk_bin_collection.uk_bin_collection.common import (
|
6
6
|
check_postcode,
|
@@ -232,11 +232,46 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
232
232
|
)
|
233
233
|
garden_dates: list[str] = get_dates_every_x_days(week[garden_week], 14, 28)
|
234
234
|
|
235
|
+
# Build a dictionary of bank holiday changes
|
236
|
+
bank_holiday_bins_url = "https://www.cheltenham.gov.uk/bank-holiday-collections"
|
237
|
+
response = requests.get(bank_holiday_bins_url)
|
238
|
+
soup = BeautifulSoup(response.content, "html.parser")
|
239
|
+
response.close()
|
240
|
+
tables = soup.find_all("table")
|
241
|
+
|
242
|
+
# Build a dictionary to modify any bank holiday collections
|
243
|
+
bh_dict = {}
|
244
|
+
for table in tables:
|
245
|
+
# extract table body
|
246
|
+
for row in table.find_all("tr")[1:]:
|
247
|
+
if row.find_all("td")[1].text.strip() == "Normal collection day":
|
248
|
+
bh_dict[
|
249
|
+
parse(
|
250
|
+
row.find_all("td")[0].text.strip(),
|
251
|
+
dayfirst=True,
|
252
|
+
fuzzy=True,
|
253
|
+
).date()
|
254
|
+
] = parse(
|
255
|
+
row.find_all("td")[0].text.strip(), dayfirst=True, fuzzy=True
|
256
|
+
).date()
|
257
|
+
else:
|
258
|
+
bh_dict[
|
259
|
+
parse(
|
260
|
+
row.find_all("td")[0].text.strip(),
|
261
|
+
dayfirst=True,
|
262
|
+
fuzzy=True,
|
263
|
+
).date()
|
264
|
+
] = parse(
|
265
|
+
row.find_all("td")[1].text.strip(), dayfirst=True, fuzzy=True
|
266
|
+
).date()
|
267
|
+
|
235
268
|
for refuse_date in refuse_dates:
|
236
|
-
collection_date = (
|
237
|
-
|
238
|
-
|
239
|
-
|
269
|
+
collection_date = datetime.strptime(refuse_date, "%d/%m/%Y") + timedelta(
|
270
|
+
days=refuse_day_offset
|
271
|
+
)
|
272
|
+
if collection_date in bh_dict:
|
273
|
+
collection_date = bh_dict[collection_date]
|
274
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
240
275
|
|
241
276
|
dict_data = {
|
242
277
|
"type": "Refuse Bin",
|
@@ -246,10 +281,12 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
246
281
|
|
247
282
|
for recycling_date in recycling_dates:
|
248
283
|
|
249
|
-
collection_date = (
|
250
|
-
|
251
|
-
|
252
|
-
|
284
|
+
collection_date = datetime.strptime(recycling_date, "%d/%m/%Y") + timedelta(
|
285
|
+
days=recycling_day_offset
|
286
|
+
)
|
287
|
+
if collection_date in bh_dict:
|
288
|
+
collection_date = bh_dict[collection_date]
|
289
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
253
290
|
|
254
291
|
dict_data = {
|
255
292
|
"type": "Recycling Bin",
|
@@ -259,10 +296,12 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
259
296
|
|
260
297
|
for garden_date in garden_dates:
|
261
298
|
|
262
|
-
collection_date = (
|
263
|
-
|
264
|
-
|
265
|
-
|
299
|
+
collection_date = datetime.strptime(garden_date, "%d/%m/%Y") + timedelta(
|
300
|
+
days=garden_day_offset
|
301
|
+
)
|
302
|
+
if collection_date in bh_dict:
|
303
|
+
collection_date = bh_dict[collection_date]
|
304
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
266
305
|
|
267
306
|
dict_data = {
|
268
307
|
"type": "Garden Waste Bin",
|
@@ -279,10 +318,12 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
279
318
|
|
280
319
|
for food_date in food_dates:
|
281
320
|
|
282
|
-
collection_date = (
|
283
|
-
|
284
|
-
|
285
|
-
|
321
|
+
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
322
|
+
days=food_day_offset
|
323
|
+
)
|
324
|
+
if collection_date in bh_dict:
|
325
|
+
collection_date = bh_dict[collection_date]
|
326
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
286
327
|
|
287
328
|
dict_data = {
|
288
329
|
"type": "Food Waste Bin",
|
@@ -313,10 +354,12 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
313
354
|
|
314
355
|
for food_date in food_dates_first:
|
315
356
|
|
316
|
-
collection_date = (
|
317
|
-
|
318
|
-
|
319
|
-
|
357
|
+
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
358
|
+
days=food_day_offset
|
359
|
+
)
|
360
|
+
if collection_date in bh_dict:
|
361
|
+
collection_date = bh_dict[collection_date]
|
362
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
320
363
|
|
321
364
|
dict_data = {
|
322
365
|
"type": "Food Waste Bin",
|
@@ -325,10 +368,12 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
325
368
|
bindata["bins"].append(dict_data)
|
326
369
|
for food_date in food_dates_second:
|
327
370
|
|
328
|
-
collection_date = (
|
329
|
-
|
330
|
-
|
331
|
-
|
371
|
+
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
372
|
+
days=second_week_offset
|
373
|
+
)
|
374
|
+
if collection_date in bh_dict:
|
375
|
+
collection_date = bh_dict[collection_date]
|
376
|
+
collection_date = collection_date.strftime("%d/%m/%Y")
|
332
377
|
|
333
378
|
dict_data = {
|
334
379
|
"type": "Food Waste Bin",
|
@@ -33,7 +33,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
33
33
|
# Wait for the postcode field to appear then populate it
|
34
34
|
inputElement_postcode = WebDriverWait(driver, 30).until(
|
35
35
|
EC.presence_of_element_located(
|
36
|
-
(By.ID, "
|
36
|
+
(By.ID, "WASTECOLLECTIONDAYS202526_LOOKUP_ADDRESSLOOKUPPOSTCODE")
|
37
37
|
)
|
38
38
|
)
|
39
39
|
inputElement_postcode.send_keys(user_postcode)
|
@@ -41,7 +41,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
41
41
|
# Click search button
|
42
42
|
findAddress = WebDriverWait(driver, 10).until(
|
43
43
|
EC.presence_of_element_located(
|
44
|
-
(By.ID, "
|
44
|
+
(By.ID, "WASTECOLLECTIONDAYS202526_LOOKUP_ADDRESSLOOKUPSEARCH")
|
45
45
|
)
|
46
46
|
)
|
47
47
|
findAddress.click()
|
@@ -51,7 +51,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
51
51
|
EC.element_to_be_clickable(
|
52
52
|
(
|
53
53
|
By.XPATH,
|
54
|
-
"//select[@id='
|
54
|
+
"//select[@id='WASTECOLLECTIONDAYS202526_LOOKUP_ADDRESSLOOKUPADDRESS']//option[contains(., '"
|
55
55
|
+ user_paon
|
56
56
|
+ "')]",
|
57
57
|
)
|
@@ -61,7 +61,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
61
61
|
# Wait for the submit button to appear, then click it to get the collection dates
|
62
62
|
submit = WebDriverWait(driver, 10).until(
|
63
63
|
EC.presence_of_element_located(
|
64
|
-
(By.ID, "
|
64
|
+
(By.ID, "WASTECOLLECTIONDAYS202526_LOOKUP_FIELD2_NEXT")
|
65
65
|
)
|
66
66
|
)
|
67
67
|
submit.click()
|
@@ -37,7 +37,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
37
37
|
collections = []
|
38
38
|
|
39
39
|
# Find section with bins in
|
40
|
-
table = soup.find_all("table", {"class": "hbcRounds"})[
|
40
|
+
table = soup.find_all("table", {"class": "hbcRounds"})[0]
|
41
41
|
|
42
42
|
# For each bin section, get the text and the list elements
|
43
43
|
for row in table.find_all("tr"):
|
@@ -73,7 +73,7 @@ uk_bin_collection/uk_bin_collection/councils/CastlepointDistrictCouncil.py,sha25
|
|
73
73
|
uk_bin_collection/uk_bin_collection/councils/CeredigionCountyCouncil.py,sha256=np9iLnMVWpMYUiHZ4sJaSaU5pOWfmiCLQ8TIrOlY48o,5924
|
74
74
|
uk_bin_collection/uk_bin_collection/councils/CharnwoodBoroughCouncil.py,sha256=tXfzMetN6wxahuGGRp2mIyCCDSL4F2aG61HhUxw6COQ,2172
|
75
75
|
uk_bin_collection/uk_bin_collection/councils/ChelmsfordCityCouncil.py,sha256=EB88D0MNJwuDZ2GX1ENc5maGYx17mnHTCtNl6s-v11E,5090
|
76
|
-
uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py,sha256=
|
76
|
+
uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py,sha256=B7OgyFKlbvu8SowAALLI8j2EnKlmbXEj65XtB27rCWI,16357
|
77
77
|
uk_bin_collection/uk_bin_collection/councils/CherwellDistrictCouncil.py,sha256=VxTe9qk93MFgtELEgVrEz3W0vYaG_32EpPmky_b4j0k,2590
|
78
78
|
uk_bin_collection/uk_bin_collection/councils/CheshireEastCouncil.py,sha256=I7Dj8LzG-Q4yrJ99jLRIwKwW5WQ9he8UksvF_YPzTxI,1681
|
79
79
|
uk_bin_collection/uk_bin_collection/councils/CheshireWestAndChesterCouncil.py,sha256=5mKZf22NgdyBY-SqV0c2q8b8IJobkoZrsfGEVUcxUyM,3544
|
@@ -106,7 +106,7 @@ uk_bin_collection/uk_bin_collection/councils/EastAyrshireCouncil.py,sha256=i3AcW
|
|
106
106
|
uk_bin_collection/uk_bin_collection/councils/EastCambridgeshireCouncil.py,sha256=aYUVE5QqTxdj8FHhCB4EiFVDJahWJD9Pq0d1upBEvXg,1501
|
107
107
|
uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py,sha256=U0VwSNIldMv5nUoiXtFgjbE0m6Kb-8W2WZQGVCNF_WI,3261
|
108
108
|
uk_bin_collection/uk_bin_collection/councils/EastHertsCouncil.py,sha256=FsHfejTGPjRUByDz157690LTD8JpqGplD_XVb7pTe3A,4862
|
109
|
-
uk_bin_collection/uk_bin_collection/councils/EastLindseyDistrictCouncil.py,sha256=
|
109
|
+
uk_bin_collection/uk_bin_collection/councils/EastLindseyDistrictCouncil.py,sha256=Laf-j0LLr7M4xmKhk8kjPNTtt66oXKYWm0ppxdUX3F0,4326
|
110
110
|
uk_bin_collection/uk_bin_collection/councils/EastLothianCouncil.py,sha256=zTp-GDWYeUIlFaqfkqGvo7XMtxJd0VbxdGgqaAwRACk,2792
|
111
111
|
uk_bin_collection/uk_bin_collection/councils/EastRenfrewshireCouncil.py,sha256=5giegMCKQ2JhVDR5M4mevVxIdhZtSW7kbuuoSkj3EGk,4361
|
112
112
|
uk_bin_collection/uk_bin_collection/councils/EastRidingCouncil.py,sha256=oL-NqriLVy_NChGASNh8qTqeakLn4iP_XzoMC6VlPGM,5216
|
@@ -142,7 +142,7 @@ uk_bin_collection/uk_bin_collection/councils/HackneyCouncil.py,sha256=vO3ugk5fcd
|
|
142
142
|
uk_bin_collection/uk_bin_collection/councils/HaltonBoroughCouncil.py,sha256=gq_CPqi6qM2oNiHhKKF1lZC86fyKL4lPhh_DN9pJZ04,5971
|
143
143
|
uk_bin_collection/uk_bin_collection/councils/HarboroughDistrictCouncil.py,sha256=uAbCgfrqkIkEKUyLVE8l72s5tzbfMFsw775i0nVRAyc,1934
|
144
144
|
uk_bin_collection/uk_bin_collection/councils/HaringeyCouncil.py,sha256=t_6AkAu4wrv8Q0WlDhWh_82I0djl5tk531Pzs-SjWzg,2647
|
145
|
-
uk_bin_collection/uk_bin_collection/councils/HarrogateBoroughCouncil.py,sha256=
|
145
|
+
uk_bin_collection/uk_bin_collection/councils/HarrogateBoroughCouncil.py,sha256=6Sf4l07YvpCmhuOMgD0VWsjfdwHPnEbbsEAsWbl4A44,2050
|
146
146
|
uk_bin_collection/uk_bin_collection/councils/HartDistrictCouncil.py,sha256=_llxT4JYYlwm20ZtS3fXwtDs6mwJyLTZBP2wBhvEpWk,2342
|
147
147
|
uk_bin_collection/uk_bin_collection/councils/HartlepoolBoroughCouncil.py,sha256=MUT1A24iZShT2p55rXEvgYwGUuw3W05Z4ZQAveehv-s,2842
|
148
148
|
uk_bin_collection/uk_bin_collection/councils/HastingsBoroughCouncil.py,sha256=9MCuit4awXSZTbZCXWBsQGX2tp2mHZ1eP1wENZdMvgA,1806
|
@@ -336,8 +336,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
336
336
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=QD4v4xpsEE0QheR_fGaNOIRMc2FatcUfKkkhAhseyVU,1159
|
337
337
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
338
338
|
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.
|
339
|
+
uk_bin_collection-0.148.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
340
|
+
uk_bin_collection-0.148.1.dist-info/METADATA,sha256=VttvCNYiRX4HrDRXZN4qtx7PnsSIRvM51WhxN0QPsDA,20914
|
341
|
+
uk_bin_collection-0.148.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
342
|
+
uk_bin_collection-0.148.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
343
|
+
uk_bin_collection-0.148.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.148.0.dist-info → uk_bin_collection-0.148.1.dist-info}/entry_points.txt
RENAMED
File without changes
|