mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 00:04:11 +01:00
adding eastleigh_gov_uk
This commit is contained in:
@@ -1242,6 +1242,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [East Renfrewshire Council](/doc/source/east_renfrewshire_gov_uk.md) / eastrenfrewshire.gov.uk
|
||||
- [East Riding of Yorkshire Council](/doc/source/eastriding_gov_uk.md) / eastriding.gov.uk
|
||||
- [Eastbourne Borough Council](/doc/source/environmentfirst_co_uk.md) / lewes-eastbourne.gov.uk
|
||||
- [Eastleigh Borough Council](/doc/source/eastleigh_gov_uk.md) / eastleigh.gov.uk
|
||||
- [Elmbridge Borough Council](/doc/source/elmbridge_gov_uk.md) / elmbridge.gov.uk
|
||||
- [Environment First](/doc/source/environmentfirst_co_uk.md) / environmentfirst.co.uk
|
||||
- [Exeter City Council](/doc/source/exeter_gov_uk.md) / exeter.gov.uk
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Eastleigh Borough Council"
|
||||
DESCRIPTION = "Source for Eastleigh Borough Council."
|
||||
URL = "https://eastleigh.gov.uk"
|
||||
TEST_CASES = {
|
||||
"100060319000": {"uprn": 100060319000},
|
||||
"100060300958": {"uprn": "100060300958"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Paper": "mdi:package-variant",
|
||||
"household": "mdi:trash-can",
|
||||
"recycling": "mdi:recycle",
|
||||
"food": "mdi:food",
|
||||
"glass": "mdi:bottle-soda",
|
||||
"garden": "mdi:leaf",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://eastleigh.gov.uk/waste-bins-and-recycling/collection-dates/your-waste-bin-and-recycling-collections"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn: str | int):
|
||||
self._uprn: str | int = uprn
|
||||
|
||||
def fetch(self):
|
||||
args = {"uprn": self._uprn}
|
||||
|
||||
# get json file
|
||||
r = requests.get(API_URL, params=args)
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
dls = soup.find_all("dl")
|
||||
|
||||
entries = []
|
||||
|
||||
for dl in dls:
|
||||
dts = dl.findAll("dt")
|
||||
for dt in dts:
|
||||
dd = dt.find_next_sibling("dd")
|
||||
if not dd:
|
||||
continue
|
||||
|
||||
try:
|
||||
# Mon, 29 Apr 2024
|
||||
date = datetime.strptime(dd.text, "%a, %d %b %Y").date()
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
icon = ICON_MAP.get(
|
||||
dt.text.strip().split(" ")[0].lower()
|
||||
) # Collection icon
|
||||
type = dt.text
|
||||
entries.append(Collection(date=date, t=type, icon=icon))
|
||||
|
||||
return entries
|
||||
36
doc/source/eastleigh_gov_uk.md
Normal file
36
doc/source/eastleigh_gov_uk.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Eastleigh Borough Council
|
||||
|
||||
Support for schedules provided by [Eastleigh Borough Council](https://eastleigh.gov.uk), serving Eastleigh Borough, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: eastleigh_gov_uk
|
||||
args:
|
||||
uprn: "UPRN"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: eastleigh_gov_uk
|
||||
args:
|
||||
uprn: "100060319000"
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
You can see your uprn in your url bar when after selecting your address at <https://eastleigh.gov.uk/waste-bins-and-recycling/collection-dates>
|
||||
|
||||
An other way to discover your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.
|
||||
Reference in New Issue
Block a user