mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 05:06:33 +01:00
Add source for chichester council UK
This commit is contained in:
@@ -356,6 +356,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Central Bedfordshire Council](/doc/source/centralbedfordshire_gov_uk.md) / centralbedfordshire.gov.uk
|
||||
- [Cheshire East Council](/doc/source/cheshire_east_gov_uk.md) / cheshireeast.gov.uk
|
||||
- [Chesterfield Borough Council](/doc/source/chesterfield_gov_uk.md) / chesterfield.gov.uk
|
||||
- [Chichester District Council](/doc/source/chichester_gov_uk.md) / chichester.gov.uk
|
||||
- [City of York Council](/doc/source/york_gov_uk.md) / york.gov.uk
|
||||
- [Colchester City Council](/doc/source/colchester_gov_uk.md) / colchester.gov.uk
|
||||
- [Cornwall Council](/doc/source/cornwall_gov_uk.md) / cornwall.gov.uk
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "chichester.gov.uk"
|
||||
DESCRIPTION = "Source for chichester.gov.uk services for Chichester"
|
||||
URL = "chichester.gov.uk"
|
||||
|
||||
#TODO
|
||||
TEST_CASES = {
|
||||
"Test_001": {"uprn": "010002476348"},
|
||||
"Test_002": {"uprn": "100062612654"},
|
||||
"Test_003": {"uprn": "100061745708"}
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"General Waste": "mdi:trash-can",
|
||||
"Recycling": "mdi:recycle",
|
||||
"Garden Recycling": "mdi:leaf",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn=None):
|
||||
self._uprn = uprn
|
||||
|
||||
def fetch(self):
|
||||
if self._uprn is None:
|
||||
raise Exception("uprn not set")
|
||||
|
||||
session = requests.Session()
|
||||
# Start a session
|
||||
r = session.get("https://www.chichester.gov.uk/checkyourbinday")
|
||||
r.raise_for_status()
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
|
||||
# Extract form submission url
|
||||
form = soup.find("form", attrs={"id":"WASTECOLLECTIONCALENDARV2_FORM"})
|
||||
form_url = form["action"]
|
||||
|
||||
# Submit form
|
||||
form_data = {
|
||||
"WASTECOLLECTIONCALENDARV2_FORMACTION_NEXT": "Submit",
|
||||
"WASTECOLLECTIONCALENDARV2_CALENDAR_UPRN": self._uprn
|
||||
}
|
||||
r = session.post(form_url, data=form_data)
|
||||
r.raise_for_status()
|
||||
|
||||
# Extract collection dates
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
entries = []
|
||||
data = soup.find_all("div", attrs={"class":"bin-days"})
|
||||
for bin in data:
|
||||
if "print-only" in bin["class"]:
|
||||
continue
|
||||
|
||||
type = bin.find("span").contents[0].replace('bin', '').strip().title()
|
||||
list_items = bin.find_all("li")
|
||||
if list_items:
|
||||
for item in list_items:
|
||||
date = datetime.strptime(item.text, "%d %B %Y").date()
|
||||
entries.append(
|
||||
Collection(
|
||||
date=date,
|
||||
t=type,
|
||||
icon=ICON_MAP.get(type),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
32
doc/source/chichester_gov_uk.md
Normal file
32
doc/source/chichester_gov_uk.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Chichester District Council
|
||||
|
||||
Support for schedules provided by [Chichester District Council](https://www.chichester.gov.uk/checkyourbinday), serving the borough of Chichester, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: chichester_gov_uk
|
||||
args:
|
||||
uprn: UPRN
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(string) (required)*
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: chichester_gov_uk
|
||||
args:
|
||||
uprn: 010002476348
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Search for your address on the [FindMyAddress service](https://www.findmyaddress.co.uk/) which displays the UPRN in the result.
|
||||
2
info.md
2
info.md
@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
| Poland | Ecoharmonogram, Warsaw |
|
||||
| Sweden | Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Ronneby Miljöteknik, SRV Återvinning, SSAM, Sysav Sophämntning, VA Syd Sophämntning |
|
||||
| Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
|
||||
| United Kingdom | Ashfield District Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Harlow Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Somerset Council, Nottingham City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Hams District Council, South Norfolk and Broadland Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United Kingdom | Ashfield District Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Harlow Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Somerset Council, Nottingham City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Hams District Council, South Norfolk and Broadland Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user