uk_bin_collection 0.127.0__py3-none-any.whl → 0.127.2__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/RushcliffeBoroughCouncil.py +29 -13
- uk_bin_collection/uk_bin_collection/councils/SouthOxfordshireCouncil.py +2 -2
- {uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/METADATA +66 -2
- {uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/RECORD +7 -7
- {uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/entry_points.txt +0 -0
@@ -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
|
-
"
|
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
|
-
"
|
48
|
+
"FF3518-find",
|
48
49
|
).click()
|
49
50
|
|
50
|
-
# Wait for the 'Select address' dropdown to
|
51
|
+
# Wait for the 'Select address' dropdown to be visible and select option matching UPRN
|
51
52
|
dropdown = WebDriverWait(driver, 10).until(
|
52
|
-
EC.
|
53
|
-
(By.ID, "
|
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
|
-
|
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
|
61
|
-
|
77
|
+
# Wait for the confirmation panel to appear
|
78
|
+
conf_div = WebDriverWait(driver, 10).until(
|
62
79
|
EC.presence_of_element_located(
|
63
|
-
(By.
|
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="
|
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.
|
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:
|
@@ -66,7 +66,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
66
66
|
"%A %d %B - %Y",
|
67
67
|
)
|
68
68
|
).strftime(date_format)
|
69
|
-
bin_type = str.capitalize(bin_info[1])
|
69
|
+
bin_type = str.capitalize(' '.join(bin_info[1:]))
|
70
70
|
# On exceptional collection schedule (e.g. around English Bank Holidays), date will be contained in the second stripped string
|
71
71
|
else:
|
72
72
|
bin_date = get_next_occurrence_from_day_month(
|
@@ -75,7 +75,7 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
75
75
|
"%A %d %B - %Y",
|
76
76
|
)
|
77
77
|
).strftime(date_format)
|
78
|
-
|
78
|
+
str.capitalize(' '.join(bin_info[2:]))
|
79
79
|
except Exception as ex:
|
80
80
|
raise ValueError(f"Error parsing bin data: {ex}")
|
81
81
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: uk_bin_collection
|
3
|
-
Version: 0.127.
|
3
|
+
Version: 0.127.2
|
4
4
|
Summary: Python Lib to collect UK Bin Data
|
5
5
|
Author: Robert Bradley
|
6
6
|
Author-email: robbrad182@gmail.com
|
@@ -256,7 +256,6 @@ Some councils need Selenium to run the scrape on behalf of Home Assistant. The e
|
|
256
256
|
```bash
|
257
257
|
docker run -d -p 4444:4444 --name selenium-chrome selenium/standalone-chrome
|
258
258
|
```
|
259
|
-
|
260
259
|
|
261
260
|
#### Step 3: Test the Selenium Server
|
262
261
|
|
@@ -288,6 +287,71 @@ docker pull selenium/standalone-chrome docker run -d -p 4444:4444 --name seleniu
|
|
288
287
|
|
289
288
|
---
|
290
289
|
|
290
|
+
### Instructions for Home Assistant OS
|
291
|
+
|
292
|
+
If you're running Home Assistant Supervised, it's possible to host the Selenium instance on the same system.
|
293
|
+
|
294
|
+
This guide is based on a Raspberry Pi 4. Instructions for other systems may vary.
|
295
|
+
|
296
|
+
#### Prerequisites
|
297
|
+
1. Install **Portainer** from Alex Belgium's add-on repository:
|
298
|
+
[github.com/alexbelgium/hassio-addons](https://github.com/alexbelgium/hassio-addons)
|
299
|
+
|
300
|
+
---
|
301
|
+
|
302
|
+
#### Step 1: Pull and Run Docker Image
|
303
|
+
|
304
|
+
Since the Raspberry Pi 4 uses an ARM64-based architecture, use the `seleniarm/standalone-chromium:latest` Docker image.
|
305
|
+
|
306
|
+
1. Open **Portainer** and navigate to the **Images** tab.
|
307
|
+
2. In the **Image** text box, enter:
|
308
|
+
|
309
|
+
```
|
310
|
+
seleniarm/standalone-chromium:latest
|
311
|
+
```
|
312
|
+
|
313
|
+
3. Click **Pull the image**.
|
314
|
+
|
315
|
+
4. Once the image is pulled, navigate to the **Containers** tab and click **Add container**.
|
316
|
+
|
317
|
+
5. Configure the container:
|
318
|
+
- **Name:** Give it a clear and descriptive name (e.g., `selenium-chromium`).
|
319
|
+
- **Image:** Enter:
|
320
|
+
|
321
|
+
```
|
322
|
+
seleniarm/standalone-chromium
|
323
|
+
```
|
324
|
+
|
325
|
+
Make sure to uncheck **Always pull the image**.
|
326
|
+
|
327
|
+
- **Network ports configuration:**
|
328
|
+
- Click **Map additional port**.
|
329
|
+
- Set both the **Host** and **Container** ports to `4444`.
|
330
|
+
|
331
|
+
6. Click **Deploy the container**.
|
332
|
+
|
333
|
+
---
|
334
|
+
|
335
|
+
#### Step 2: Configure UKBinCollectionData Integration
|
336
|
+
|
337
|
+
1. **Add the integration** in Home Assistant.
|
338
|
+
|
339
|
+
2. On the second stage of the integration setup wizard:
|
340
|
+
- Ensure that `http://localhost:4444` shows as accessible.
|
341
|
+
- If not, verify that the Selenium container is running in Portainer.
|
342
|
+
|
343
|
+
3. Enter the required information for the integration.
|
344
|
+
|
345
|
+
4. In the **Remote Selenium Server** text box, enter:
|
346
|
+
|
347
|
+
```
|
348
|
+
http://<HA IP address>:4444
|
349
|
+
```
|
350
|
+
|
351
|
+
Replace `<HA IP address>` with the IP address of your Home Assistant system.
|
352
|
+
|
353
|
+
---
|
354
|
+
|
291
355
|
## Reports
|
292
356
|
|
293
357
|
### Nightly Full Integration Test Reports:
|
@@ -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=
|
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
|
@@ -228,7 +228,7 @@ uk_bin_collection/uk_bin_collection/councils/SouthHamsDistrictCouncil.py,sha256=
|
|
228
228
|
uk_bin_collection/uk_bin_collection/councils/SouthKestevenDistrictCouncil.py,sha256=_26ouWln5VrKiIFcp2b6ZzuwCKpp3aNcS2n5d4-8NsA,6210
|
229
229
|
uk_bin_collection/uk_bin_collection/councils/SouthLanarkshireCouncil.py,sha256=fj-eZI0yrvQVCv8GvhcovZ3b9bV6Xv_ws3IunWjnv4U,3126
|
230
230
|
uk_bin_collection/uk_bin_collection/councils/SouthNorfolkCouncil.py,sha256=C2qIZjjbl9JnuukX9OH2RbfP0hSdp3uX76APGY33qKs,4622
|
231
|
-
uk_bin_collection/uk_bin_collection/councils/SouthOxfordshireCouncil.py,sha256=
|
231
|
+
uk_bin_collection/uk_bin_collection/councils/SouthOxfordshireCouncil.py,sha256=uVvyqQ0jr4VryjY5MU-c5PpYcrZvqt16oxAH3ekMjA4,3890
|
232
232
|
uk_bin_collection/uk_bin_collection/councils/SouthRibbleCouncil.py,sha256=OdexbeiI5WsCfjlsnHjAce8oGF5fW-n7q2XOuxcpHzw,3604
|
233
233
|
uk_bin_collection/uk_bin_collection/councils/SouthStaffordshireDistrictCouncil.py,sha256=ACQMHWyamnj1ag3gNF-8Jhp-DKUok1GhFdnzH4nCzwU,3201
|
234
234
|
uk_bin_collection/uk_bin_collection/councils/SouthTynesideCouncil.py,sha256=dxXGrJfg_fn2IPTBgq6Duwy0WY8GYLafMuisaCjOnbs,3426
|
@@ -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.
|
302
|
-
uk_bin_collection-0.127.
|
303
|
-
uk_bin_collection-0.127.
|
304
|
-
uk_bin_collection-0.127.
|
305
|
-
uk_bin_collection-0.127.
|
301
|
+
uk_bin_collection-0.127.2.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
302
|
+
uk_bin_collection-0.127.2.dist-info/METADATA,sha256=WfUAtwObkc-bC7GPsdxbpgsyrhAUA5yPuf7-6ghAfgc,19549
|
303
|
+
uk_bin_collection-0.127.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
304
|
+
uk_bin_collection-0.127.2.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
305
|
+
uk_bin_collection-0.127.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.127.0.dist-info → uk_bin_collection-0.127.2.dist-info}/entry_points.txt
RENAMED
File without changes
|