uk_bin_collection 0.127.0__py3-none-any.whl → 0.127.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of uk_bin_collection might be problematic. Click here for more details.

@@ -7,6 +7,7 @@ from selenium.webdriver.support.wait import WebDriverWait
7
7
  from uk_bin_collection.uk_bin_collection.common import *
8
8
  from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
9
9
 
10
+ import string
10
11
 
11
12
  # import the wonderful Beautiful Soup and the URL grabber
12
13
  class CouncilClass(AbstractGetBinDataClass):
@@ -37,42 +38,57 @@ class CouncilClass(AbstractGetBinDataClass):
37
38
  # Populate postcode field
38
39
  inputElement_postcode = driver.find_element(
39
40
  By.ID,
40
- "ctl00_ContentPlaceHolder1_FF3518TB",
41
+ "FF3518-text",
41
42
  )
42
43
  inputElement_postcode.send_keys(user_postcode)
43
44
 
44
45
  # Click search button
45
46
  driver.find_element(
46
47
  By.ID,
47
- "ctl00_ContentPlaceHolder1_FF3518BTN",
48
+ "FF3518-find",
48
49
  ).click()
49
50
 
50
- # Wait for the 'Select address' dropdown to appear and select option matching UPRN
51
+ # Wait for the 'Select address' dropdown to be visible and select option matching UPRN
51
52
  dropdown = WebDriverWait(driver, 10).until(
52
- EC.presence_of_element_located(
53
- (By.ID, "ctl00_ContentPlaceHolder1_FF3518DDL")
53
+ EC.visibility_of_element_located(
54
+ (By.ID, "FF3518-list")
54
55
  )
55
56
  )
57
+
56
58
  # Create a 'Select' for it, then select the matching URPN option
57
59
  dropdownSelect = Select(dropdown)
58
- dropdownSelect.select_by_value("U" + user_uprn)
60
+ found_uprn = False
61
+ for o in dropdownSelect.options:
62
+ ov = o.get_dom_attribute("value")
63
+ if "U" + user_uprn in ov:
64
+ dropdownSelect.select_by_value(ov)
65
+ found_uprn = True
66
+ break
67
+
68
+ if not found_uprn:
69
+ raise Exception("could not find UPRN " + user_uprn + " in list")
70
+
71
+ # Click submit button
72
+ driver.find_element(
73
+ By.ID,
74
+ "submit-button",
75
+ ).click()
59
76
 
60
- # Wait for the submit button to appear, then click it to get the collection dates
61
- submit = WebDriverWait(driver, 10).until(
77
+ # Wait for the confirmation panel to appear
78
+ conf_div = WebDriverWait(driver, 10).until(
62
79
  EC.presence_of_element_located(
63
- (By.ID, "ctl00_ContentPlaceHolder1_btnSubmit")
80
+ (By.CLASS_NAME, "ss_confPanel")
64
81
  )
65
82
  )
66
- submit.click()
67
83
 
68
84
  soup = BeautifulSoup(driver.page_source, features="html.parser")
69
85
 
70
- bins_text = soup.find("div", id="ctl00_ContentPlaceHolder1_pnlConfirmation")
86
+ bins_text = soup.find("div", id="body-content")
71
87
 
72
88
  if bins_text:
73
89
  results = re.findall(
74
- "Your (.*?) bin will next be collected on (\d\d?\/\d\d?\/\d{4})",
75
- bins_text.find("div", {"class": "ss_confPanel"}).get_text(),
90
+ r"Your (.*?) bin will next be collected on (\d\d?\/\d\d?\/\d{4})",
91
+ bins_text.get_text(),
76
92
  )
77
93
  if results:
78
94
  for result in results:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uk_bin_collection
3
- Version: 0.127.0
3
+ Version: 0.127.1
4
4
  Summary: Python Lib to collect UK Bin Data
5
5
  Author: Robert Bradley
6
6
  Author-email: robbrad182@gmail.com
@@ -210,7 +210,7 @@ uk_bin_collection/uk_bin_collection/councils/RotherDistrictCouncil.py,sha256=-fd
210
210
  uk_bin_collection/uk_bin_collection/councils/RotherhamCouncil.py,sha256=LtMPM8lj5bfReDR4buHEo-aRC_HTBIeo1nf8GE5-R80,1790
211
211
  uk_bin_collection/uk_bin_collection/councils/RoyalBoroughofGreenwich.py,sha256=BZzLmWK_VONOmMpSrLrnKtJaOrrepm6aStfKGVcgf9Y,3487
212
212
  uk_bin_collection/uk_bin_collection/councils/RugbyBoroughCouncil.py,sha256=qwyi2K1p1erSawthC1QD1_oYghLfXFlXMdClszZTitU,4190
213
- uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py,sha256=wMtiYRirT585vtsEOIyXHugk7aEj3pvyVWBaAePdqtE,4005
213
+ uk_bin_collection/uk_bin_collection/councils/RushcliffeBoroughCouncil.py,sha256=EZGf0en7lBXv3IOkrObxCXLNC6FFCkqqGlIMNFrQvPw,4296
214
214
  uk_bin_collection/uk_bin_collection/councils/RushmoorCouncil.py,sha256=ZsGnXjoEaOS6U7fI0w7-uqxayAHdNVKsJi2fqIWEls8,3375
215
215
  uk_bin_collection/uk_bin_collection/councils/SalfordCityCouncil.py,sha256=XUGemp2cdzsvkWjnv2m4YKTMcoKDUfIlVy3YucX-_o4,2601
216
216
  uk_bin_collection/uk_bin_collection/councils/SandwellBoroughCouncil.py,sha256=shJhvqDcha2ypDCSfhss59G95jNaWBuMnVIxJiZXcY8,3110
@@ -298,8 +298,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
298
298
  uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
299
299
  uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
300
300
  uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
301
- uk_bin_collection-0.127.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
302
- uk_bin_collection-0.127.0.dist-info/METADATA,sha256=cEmdgh6m1R0NjncpNXCC69NwwpGJANfqoSc1mAvW7S4,17745
303
- uk_bin_collection-0.127.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
304
- uk_bin_collection-0.127.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
305
- uk_bin_collection-0.127.0.dist-info/RECORD,,
301
+ uk_bin_collection-0.127.1.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
302
+ uk_bin_collection-0.127.1.dist-info/METADATA,sha256=gT5fjaFHu1r-dhKbbEI-vxJxYVFyWlmQRl7xGzBOUi4,17745
303
+ uk_bin_collection-0.127.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
304
+ uk_bin_collection-0.127.1.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
305
+ uk_bin_collection-0.127.1.dist-info/RECORD,,