uk_bin_collection 0.143.1__py3-none-any.whl → 0.143.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.
@@ -21,7 +21,7 @@ class CouncilClass(AbstractGetBinDataClass):
21
21
  def parse_data(self, page: str, **kwargs) -> dict:
22
22
  driver = None
23
23
  try:
24
- # Get and check UPRN
24
+ # Get and check UPRN
25
25
  user_uprn = kwargs.get("uprn")
26
26
  user_postcode = kwargs.get("postcode")
27
27
  check_uprn(user_uprn)
@@ -73,7 +73,10 @@ class CouncilClass(AbstractGetBinDataClass):
73
73
  # Click search button
74
74
  findAddress = WebDriverWait(driver, 10).until(
75
75
  EC.presence_of_element_located(
76
- (By.ID, "ContentPlaceHolder1_CollectionDayLookup2_Button_SelectAddress")
76
+ (
77
+ By.ID,
78
+ "ContentPlaceHolder1_CollectionDayLookup2_Button_SelectAddress",
79
+ )
77
80
  )
78
81
  )
79
82
  findAddress.click()
@@ -89,7 +92,9 @@ class CouncilClass(AbstractGetBinDataClass):
89
92
  bin_tables = soup.find_all("table")
90
93
 
91
94
  for bin_table in bin_tables:
92
- bin_text = bin_table.find("td", id=re.compile("CollectionDayLookup2_td_"))
95
+ bin_text = bin_table.find(
96
+ "td", id=re.compile("CollectionDayLookup2_td_")
97
+ )
93
98
  if not bin_text:
94
99
  continue
95
100
 
@@ -112,7 +117,9 @@ class CouncilClass(AbstractGetBinDataClass):
112
117
  if date_soup.text.strip().lower() == "today":
113
118
  date = datetime.now().date()
114
119
  else:
115
- date = datetime.strptime(date_str.split(" ")[1], "%d/%m/%Y").date()
120
+ date = datetime.strptime(
121
+ date_str.split(" ")[1], "%d/%m/%Y"
122
+ ).date()
116
123
 
117
124
  except ValueError:
118
125
  continue
@@ -132,4 +139,4 @@ class CouncilClass(AbstractGetBinDataClass):
132
139
  # This block ensures that the driver is closed regardless of an exception
133
140
  if driver:
134
141
  driver.quit()
135
- return bindata
142
+ return bindata
@@ -89,7 +89,9 @@ class CouncilClass(AbstractGetBinDataClass):
89
89
  property.click()
90
90
 
91
91
  upcoming_scheduled_collections = WebDriverWait(driver, 10).until(
92
- EC.presence_of_element_located((By.ID, "upcoming-scheduled-collections"))
92
+ EC.presence_of_element_located(
93
+ (By.ID, "upcoming-scheduled-collections")
94
+ )
93
95
  )
94
96
 
95
97
  soup = BeautifulSoup(driver.page_source, features="html.parser")
@@ -125,4 +127,4 @@ class CouncilClass(AbstractGetBinDataClass):
125
127
  # This block ensures that the driver is closed regardless of an exception
126
128
  if driver:
127
129
  driver.quit()
128
- return bindata
130
+ return bindata
@@ -48,7 +48,11 @@ class CouncilClass(AbstractGetBinDataClass):
48
48
  for tag in strong:
49
49
  parent = tag.parent
50
50
  bin_type = (
51
- (parent.text).split("-")[1].strip().replace("\xa0", " ").split(" and ")
51
+ (parent.text)
52
+ .split("-")[1]
53
+ .strip()
54
+ .replace("\xa0", " ")
55
+ .split(" and ")
52
56
  )
53
57
  for bin in bin_type:
54
58
  dict_data = {
@@ -104,7 +108,9 @@ class CouncilClass(AbstractGetBinDataClass):
104
108
  table_data = []
105
109
  for row in table.find("tbody").find_all("tr"):
106
110
  # Extract cell data from each <td> tag
107
- row_data = [cell.get_text(strip=True) for cell in row.find_all("td")]
111
+ row_data = [
112
+ cell.get_text(strip=True) for cell in row.find_all("td")
113
+ ]
108
114
  table_data.append(row_data)
109
115
 
110
116
  else:
@@ -112,7 +118,9 @@ class CouncilClass(AbstractGetBinDataClass):
112
118
 
113
119
  collection_day = (table_data[0])[1]
114
120
 
115
- current_week_bins = [bin for bin in bin_weeks if bin["week"] == current_week]
121
+ current_week_bins = [
122
+ bin for bin in bin_weeks if bin["week"] == current_week
123
+ ]
116
124
  next_week_bins = [bin for bin in bin_weeks if bin["week"] != current_week]
117
125
 
118
126
  days_of_week = [
@@ -168,4 +176,4 @@ class CouncilClass(AbstractGetBinDataClass):
168
176
  # This block ensures that the driver is closed regardless of an exception
169
177
  if driver:
170
178
  driver.quit()
171
- return bindata
179
+ return bindata
@@ -43,88 +43,71 @@ class CouncilClass(AbstractGetBinDataClass):
43
43
  postcode_box = wait.until(
44
44
  EC.element_to_be_clickable(
45
45
  (
46
- By.ID,
47
- "ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_txtPostCode",
46
+ By.XPATH,
47
+ "//input[@id='postcode']",
48
48
  )
49
49
  )
50
50
  )
51
51
  postcode_box.send_keys(user_postcode)
52
52
  postcode_btn_present = wait.until(
53
53
  EC.presence_of_element_located(
54
- (
55
- By.ID,
56
- "ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_btnSearchAddress",
57
- )
58
- )
59
- )
60
- postcode_btn = wait.until(
61
- EC.element_to_be_clickable(
62
54
  (
63
55
  By.XPATH,
64
- '//*[@id="ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_btnSearchAddress"]',
56
+ "//button[contains(text(),'Look up Address')]",
65
57
  )
66
58
  )
67
59
  )
68
60
 
69
- postcode_btn.send_keys(Keys.ENTER)
61
+ postcode_btn_present.send_keys(Keys.RETURN)
70
62
 
71
63
  dropdown_present = wait.until(
72
64
  EC.presence_of_element_located(
73
65
  (
74
66
  By.XPATH,
75
- '//*[@id="ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_ddlAddressList"]/option',
76
- )
77
- )
78
- )
79
- address_dropdown = wait.until(
80
- EC.element_to_be_clickable(
81
- (
82
- By.ID,
83
- "ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_ddlAddressList",
67
+ '//option[contains(text(),"Select an address")]/parent::select',
84
68
  )
85
69
  )
86
70
  )
87
71
 
88
- dropdown_present.click()
72
+ dropdown_select = Select(dropdown_present)
73
+
74
+ dropdown_select.select_by_value(user_uprn)
89
75
 
90
- dropdownSelect = Select(address_dropdown)
91
- dropdownSelect.select_by_value(str(user_uprn))
92
- results = wait.until(
76
+ result = wait.until(
93
77
  EC.presence_of_element_located(
94
78
  (
95
- By.ID,
96
- "ctl00_ctl48_g_eea1a8ba_4306_488e_96f2_97f22038e29f_ctl00_BinResultsDetails",
79
+ By.XPATH,
80
+ "//div[@class='lcc-bins']",
97
81
  )
98
82
  )
99
83
  )
100
84
 
101
85
  data = {"bins": []} # dictionary for data
102
- soup = BeautifulSoup(driver.page_source, "html.parser")
103
-
104
- bin_types = soup.find_all("ul", class_="binCollectionTimesList")
105
-
106
- for bin_collection_dates in bin_types:
107
-
108
- bin_collection_list = bin_collection_dates.find_all("li")
109
-
110
- if bin_collection_list:
111
- collection_dates = [
112
- date.text.strip() for date in bin_collection_list
113
- ]
114
-
115
- # Convert the collection dates to the desired format
116
- formatted_dates = [
117
- datetime.strptime(date, "%A %d %b %Y").strftime(date_format)
118
- for date in collection_dates
119
- ]
120
-
121
- # Extract the type of bin from the header
122
- bin_type = bin_collection_dates.find_previous("h3").text.split()[0]
86
+ soup = BeautifulSoup(
87
+ result.get_attribute("innerHTML"), features="html.parser"
88
+ )
123
89
 
124
- # Adding data to the 'bins' dictionary for each date
125
- for date in formatted_dates:
126
- dict_data = {"type": bin_type, "collectionDate": date}
127
- data["bins"].append(dict_data)
90
+ bin_sections = soup.select("div.lcc-bin:not(.lcc-bin--calendar)")
91
+
92
+ for section in bin_sections:
93
+ h3_text = section.find("h3").get_text(strip=True)
94
+ bin_type = h3_text.split()[0] # e.g., 'Black', 'Brown', 'Green'
95
+
96
+ # Find all <li> elements inside the bin days list
97
+ date_elements = section.select("div.lcc-bin__days li")
98
+ for li in date_elements:
99
+ raw_date = li.get_text(strip=True)
100
+ if not raw_date:
101
+ continue
102
+ try:
103
+ formatted_date = datetime.strptime(
104
+ raw_date, "%A %d %b %Y"
105
+ ).strftime(date_format)
106
+ data["bins"].append(
107
+ {"type": bin_type, "collectionDate": formatted_date}
108
+ )
109
+ except ValueError:
110
+ print(f"Skipping unparseable date: {raw_date}")
128
111
  except Exception as e:
129
112
  # Here you can log the exception if needed
130
113
  print(f"An error occurred: {e}")
@@ -59,4 +59,3 @@ class CouncilClass(AbstractGetBinDataClass):
59
59
  if driver:
60
60
  driver.quit()
61
61
  return data
62
-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.143.1
3
+ Version: 0.143.3
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -23,7 +23,7 @@ uk_bin_collection/uk_bin_collection/councils/ArgyllandButeCouncil.py,sha256=fJ0U
23
23
  uk_bin_collection/uk_bin_collection/councils/ArmaghBanbridgeCraigavonCouncil.py,sha256=o9NBbVCTdxKXnpYbP8-zxe1Gh8s57vwfV75Son_sAHE,2863
24
24
  uk_bin_collection/uk_bin_collection/councils/ArunCouncil.py,sha256=yfhthv9nuogP19VOZ3TYQrq51qqjiCZcSel4sXhiKjs,4012
25
25
  uk_bin_collection/uk_bin_collection/councils/AshfieldDistrictCouncil.py,sha256=fhX7S_A3jqoND7NE6qITPMPvdk3FJSKZ3Eoa5RtSg3I,4247
26
- uk_bin_collection/uk_bin_collection/councils/AshfordBoroughCouncil.py,sha256=4ebRyX2qZRbZdomuN1aJOSXij-r7YagRBQvV1vyPkqY,5059
26
+ uk_bin_collection/uk_bin_collection/councils/AshfordBoroughCouncil.py,sha256=kuL7ujTdbuvExy84Wl2LVrPlcmnpU-mgBIW3krEBXew,5227
27
27
  uk_bin_collection/uk_bin_collection/councils/AylesburyValeCouncil.py,sha256=LouqjspEMt1TkOGqWHs2zkxwOETIy3n7p64uKIlAgUg,2401
28
28
  uk_bin_collection/uk_bin_collection/councils/BCPCouncil.py,sha256=W7QBx6Mgso8RYosuXsaYo3GGNAu-tiyBSmuYxr1JSOU,1707
29
29
  uk_bin_collection/uk_bin_collection/councils/BaberghDistrictCouncil.py,sha256=1eXdST58xFRMdYl8AGNG_EwyQeLa31WSWUe882hQ2ec,6329
@@ -101,7 +101,7 @@ uk_bin_collection/uk_bin_collection/councils/EalingCouncil.py,sha256=UhNXGi-_6NY
101
101
  uk_bin_collection/uk_bin_collection/councils/EastAyrshireCouncil.py,sha256=i3AcWkeAnk7rD59nOm0QCSH7AggqjUAdwsXuSIC8ZJE,1614
102
102
  uk_bin_collection/uk_bin_collection/councils/EastCambridgeshireCouncil.py,sha256=aYUVE5QqTxdj8FHhCB4EiFVDJahWJD9Pq0d1upBEvXg,1501
103
103
  uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py,sha256=U0VwSNIldMv5nUoiXtFgjbE0m6Kb-8W2WZQGVCNF_WI,3261
104
- uk_bin_collection/uk_bin_collection/councils/EastHertsCouncil.py,sha256=gujFsqn3j4YGudXxhJcLiO_pVYHnY_rd6GeZHzSqqs4,4823
104
+ uk_bin_collection/uk_bin_collection/councils/EastHertsCouncil.py,sha256=FsHfejTGPjRUByDz157690LTD8JpqGplD_XVb7pTe3A,4862
105
105
  uk_bin_collection/uk_bin_collection/councils/EastLindseyDistrictCouncil.py,sha256=RSOTD1MIXSW27eGf3TixCiJK4HtSJnpfME2CjalDeXs,4326
106
106
  uk_bin_collection/uk_bin_collection/councils/EastLothianCouncil.py,sha256=zTp-GDWYeUIlFaqfkqGvo7XMtxJd0VbxdGgqaAwRACk,2792
107
107
  uk_bin_collection/uk_bin_collection/councils/EastRenfrewshireCouncil.py,sha256=5giegMCKQ2JhVDR5M4mevVxIdhZtSW7kbuuoSkj3EGk,4361
@@ -142,7 +142,7 @@ uk_bin_collection/uk_bin_collection/councils/HartDistrictCouncil.py,sha256=_llxT
142
142
  uk_bin_collection/uk_bin_collection/councils/HartlepoolBoroughCouncil.py,sha256=MUT1A24iZShT2p55rXEvgYwGUuw3W05Z4ZQAveehv-s,2842
143
143
  uk_bin_collection/uk_bin_collection/councils/HastingsBoroughCouncil.py,sha256=9MCuit4awXSZTbZCXWBsQGX2tp2mHZ1eP1wENZdMvgA,1806
144
144
  uk_bin_collection/uk_bin_collection/councils/HerefordshireCouncil.py,sha256=JpQhkWM6Jeuzf1W7r0HqvtVnEqNi18nhwJX70YucdsI,1848
145
- uk_bin_collection/uk_bin_collection/councils/HertsmereBoroughCouncil.py,sha256=k6MKZ3Xa-_a0oIpH5Rv5haYVq1eRHKSCiI6UAqAVTUk,6274
145
+ uk_bin_collection/uk_bin_collection/councils/HertsmereBoroughCouncil.py,sha256=ZbSsmqHStd2JtTMAq1Bhcvsj1BYp6ijELyOjZFX2GSw,6435
146
146
  uk_bin_collection/uk_bin_collection/councils/HighPeakCouncil.py,sha256=x7dfy8mdt2iGl8qJxHb-uBh4u0knmi9MJ6irOJw9WYA,4805
147
147
  uk_bin_collection/uk_bin_collection/councils/HighlandCouncil.py,sha256=GNxDU65QuZHV5va2IrKtcJ6TQoDdwmV03JvkVqOauP4,3291
148
148
  uk_bin_collection/uk_bin_collection/councils/HinckleyandBosworthBoroughCouncil.py,sha256=51vXTKrstfJhb7cLCcrsvA9qKCsptyNMZvy7ML9DasM,2344
@@ -156,7 +156,7 @@ uk_bin_collection/uk_bin_collection/councils/KingstonUponThamesCouncil.py,sha256
156
156
  uk_bin_collection/uk_bin_collection/councils/KirkleesCouncil.py,sha256=WPM7koIqK5Wz-iT9Mds6AptihGZtl4KZhkVTcT9cx_c,2762
157
157
  uk_bin_collection/uk_bin_collection/councils/KnowsleyMBCouncil.py,sha256=VdlWDESoHfr_X0r8-UMaLMUQhKZOa2BnpVPkX-1u3EQ,5605
158
158
  uk_bin_collection/uk_bin_collection/councils/LancasterCityCouncil.py,sha256=FmHT6oyD4BwWuhxA80PHnGA7HPrLuyjP_54Cg8hT6k4,2537
159
- uk_bin_collection/uk_bin_collection/councils/LeedsCityCouncil.py,sha256=t4nUxHJ_UKLyLHqJkngTiSodJcYalfw_Jr4WU0uMMc0,5134
159
+ uk_bin_collection/uk_bin_collection/councils/LeedsCityCouncil.py,sha256=VWdhw6qvCTj3EhFHf046xPWgc6szeFW2Xbt6W2J0e6w,4371
160
160
  uk_bin_collection/uk_bin_collection/councils/LeicesterCityCouncil.py,sha256=o3kE8sjThQa4_AvSK5NH8VH7jWFO9MMPgoqLOTjyh0w,1851
161
161
  uk_bin_collection/uk_bin_collection/councils/LichfieldDistrictCouncil.py,sha256=l3zgTWuKOW8fgb8PmXv0OTI6HaiGBPndefNQk8MM4oY,1810
162
162
  uk_bin_collection/uk_bin_collection/councils/LincolnCouncil.py,sha256=aUCqjHuk0sLtx83a-2agcLIMgEbfqjltXRCBRXT9J-8,3733
@@ -315,7 +315,7 @@ uk_bin_collection/uk_bin_collection/councils/WestSuffolkCouncil.py,sha256=9i8AQH
315
315
  uk_bin_collection/uk_bin_collection/councils/WiganBoroughCouncil.py,sha256=3gqFA4-BVx_In6QOu3KUNqPN4Fkn9iMlZTeopMK9p6A,3746
316
316
  uk_bin_collection/uk_bin_collection/councils/WiltshireCouncil.py,sha256=Q0ooHTQb9ynMXpSNBPk7XXEjI7zcHst3id4wxGdmVx4,5698
317
317
  uk_bin_collection/uk_bin_collection/councils/WinchesterCityCouncil.py,sha256=W2k00N5n9-1MzjMEqsNjldsQdOJPEPMjK7OGSinZm5Y,4335
318
- uk_bin_collection/uk_bin_collection/councils/WindsorAndMaidenheadCouncil.py,sha256=d294otB0MRTLNx0Axf8Giy2ggzRRqn8ABN35wyu0l5w,2295
318
+ uk_bin_collection/uk_bin_collection/councils/WindsorAndMaidenheadCouncil.py,sha256=VWtFgypXL1wKQ63NmV-_O9odOkbDmv3uCQwrv8g9lMI,2294
319
319
  uk_bin_collection/uk_bin_collection/councils/WirralCouncil.py,sha256=X_e9zXEZAl_Mp6nPORHc9CTmf3QHdoMY3BCnKrXEr1I,2131
320
320
  uk_bin_collection/uk_bin_collection/councils/WokingBoroughCouncil.py,sha256=37igH9g0xe4XIhRhcJ-ZJBU8MxTp5yzgpadWbdE33Yg,5205
321
321
  uk_bin_collection/uk_bin_collection/councils/WokinghamBoroughCouncil.py,sha256=H8aFHlacwV07X-6T9RQua4irqDA0cIQrF4O1FfPR7yI,4114
@@ -328,8 +328,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
328
328
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
329
329
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
330
330
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
331
- uk_bin_collection-0.143.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
332
- uk_bin_collection-0.143.1.dist-info/METADATA,sha256=34RWNbJRnidJu_zctdcxYVnNzs5UQCTUxlwSkZ8vdM0,19851
333
- uk_bin_collection-0.143.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
334
- uk_bin_collection-0.143.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
335
- uk_bin_collection-0.143.1.dist-info/RECORD,,
331
+ uk_bin_collection-0.143.3.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
332
+ uk_bin_collection-0.143.3.dist-info/METADATA,sha256=gpr8rHY2BBj60Wn_gfXQx6tm8PbcGdchn6kgvm7JW-E,19851
333
+ uk_bin_collection-0.143.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
334
+ uk_bin_collection-0.143.3.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
335
+ uk_bin_collection-0.143.3.dist-info/RECORD,,