uk_bin_collection 0.146.0__py3-none-any.whl → 0.146.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.
@@ -35,41 +35,62 @@ DAYS_OF_WEEK = {
35
35
  def get_bank_holiday_changes(driver: WebDriver) -> Dict[str, str]:
36
36
  """Fetch and parse bank holiday collection changes from the council website."""
37
37
  bank_holiday_url = "https://www.hillingdon.gov.uk/bank-holiday-collections"
38
- driver.get(bank_holiday_url)
38
+ changes: Dict[str, str] = {}
39
39
 
40
- # Wait for page to load
41
- wait = WebDriverWait(driver, 10)
42
- wait.until(EC.presence_of_element_located((By.TAG_NAME, "table")))
40
+ try:
41
+ driver.get(bank_holiday_url)
43
42
 
44
- # Parse the page
45
- soup = BeautifulSoup(driver.page_source, features="html.parser")
46
- changes: Dict[str, str] = {}
43
+ # Check if the page is a 404 or has an error
44
+ if "404" in driver.title or "Page not found" in driver.page_source:
45
+ print("Bank holiday page not found (404).")
46
+ return changes
47
47
 
48
- # Find all tables with collection changes
49
- tables = soup.find_all("table")
50
- for table in tables:
51
- # Check if this is a collection changes table
52
- headers = [th.text.strip() for th in table.find_all("th")]
53
- if "Normal collection day" in headers and "Revised collection day" in headers:
54
- # Process each row
55
- for row in table.find_all("tr")[1:]: # Skip header row
56
- cols = row.find_all("td")
57
- if len(cols) >= 2:
58
- normal_date = cols[0].text.strip()
59
- revised_date = cols[1].text.strip()
60
-
61
- # Parse dates
62
- try:
63
- normal_date = parse(normal_date, fuzzy=True).strftime(
64
- "%d/%m/%Y"
65
- )
66
- revised_date = parse(revised_date, fuzzy=True).strftime(
67
- "%d/%m/%Y"
68
- )
69
- changes[normal_date] = revised_date
70
- except Exception as e:
71
- print(f"Error parsing dates: {e}")
72
- continue
48
+ # Wait for page to load
49
+ wait = WebDriverWait(driver, 10)
50
+ try:
51
+ wait.until(EC.presence_of_element_located((By.TAG_NAME, "table")))
52
+ except TimeoutException:
53
+ print("No tables found on the bank holiday page.")
54
+ return changes
55
+
56
+ # Parse the page
57
+ soup = BeautifulSoup(driver.page_source, features="html.parser")
58
+
59
+ # Find all tables with collection changes
60
+ tables = soup.find_all("table")
61
+ if not tables:
62
+ print("No relevant tables found on the bank holiday page.")
63
+ return changes
64
+
65
+ for table in tables:
66
+ # Check if this is a collection changes table
67
+ headers = [th.text.strip() for th in table.find_all("th")]
68
+ if (
69
+ "Normal collection day" in headers
70
+ and "Revised collection day" in headers
71
+ ):
72
+ # Process each row
73
+ for row in table.find_all("tr")[1:]: # Skip header row
74
+ cols = row.find_all("td")
75
+ if len(cols) >= 2:
76
+ normal_date = cols[0].text.strip()
77
+ revised_date = cols[1].text.strip()
78
+
79
+ # Parse dates
80
+ try:
81
+ normal_date = parse(normal_date, fuzzy=True).strftime(
82
+ "%d/%m/%Y"
83
+ )
84
+ revised_date = parse(revised_date, fuzzy=True).strftime(
85
+ "%d/%m/%Y"
86
+ )
87
+ changes[normal_date] = revised_date
88
+ except Exception as e:
89
+ print(f"Error parsing dates: {e}")
90
+ continue
91
+
92
+ except Exception as e:
93
+ print(f"An error occurred while fetching bank holiday changes: {e}")
73
94
 
74
95
  return changes
75
96
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.146.0
3
+ Version: 0.146.1
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -148,7 +148,7 @@ uk_bin_collection/uk_bin_collection/councils/HerefordshireCouncil.py,sha256=JpQh
148
148
  uk_bin_collection/uk_bin_collection/councils/HertsmereBoroughCouncil.py,sha256=ZbSsmqHStd2JtTMAq1Bhcvsj1BYp6ijELyOjZFX2GSw,6435
149
149
  uk_bin_collection/uk_bin_collection/councils/HighPeakCouncil.py,sha256=x7dfy8mdt2iGl8qJxHb-uBh4u0knmi9MJ6irOJw9WYA,4805
150
150
  uk_bin_collection/uk_bin_collection/councils/HighlandCouncil.py,sha256=GNxDU65QuZHV5va2IrKtcJ6TQoDdwmV03JvkVqOauP4,3291
151
- uk_bin_collection/uk_bin_collection/councils/Hillingdon.py,sha256=R1enDv5gjwCUT3HKgj8C87xWrwvrutAN6XLu5P7tef8,10532
151
+ uk_bin_collection/uk_bin_collection/councils/Hillingdon.py,sha256=2OUp0iYO1YeZuTq0XRUalgoay5JRZgfHKKEwYzdMAU0,11291
152
152
  uk_bin_collection/uk_bin_collection/councils/HinckleyandBosworthBoroughCouncil.py,sha256=51vXTKrstfJhb7cLCcrsvA9qKCsptyNMZvy7ML9DasM,2344
153
153
  uk_bin_collection/uk_bin_collection/councils/HullCityCouncil.py,sha256=UHcesBoctFVcXDYuwfag43KbcJcopkEDzJ-54NxtK0Q,1851
154
154
  uk_bin_collection/uk_bin_collection/councils/HuntingdonDistrictCouncil.py,sha256=dGyhhG6HRjQ2SPeiRwUPTGlk9dPIslagV2k0GjEOn1s,1587
@@ -332,8 +332,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
332
332
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=QD4v4xpsEE0QheR_fGaNOIRMc2FatcUfKkkhAhseyVU,1159
333
333
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
334
334
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
335
- uk_bin_collection-0.146.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
336
- uk_bin_collection-0.146.0.dist-info/METADATA,sha256=HDx_ThJ-YHiak_qHaFdhBG4hOT-xeil2DR5LO4V_kAA,19858
337
- uk_bin_collection-0.146.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
338
- uk_bin_collection-0.146.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
339
- uk_bin_collection-0.146.0.dist-info/RECORD,,
335
+ uk_bin_collection-0.146.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
336
+ uk_bin_collection-0.146.1.dist-info/METADATA,sha256=Q2CxbBh-CbGhd-HLj-lH0U3mDLxZWv3JgBXKMvaWNh0,19858
337
+ uk_bin_collection-0.146.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
338
+ uk_bin_collection-0.146.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
339
+ uk_bin_collection-0.146.1.dist-info/RECORD,,