New Source: Cherwell District Council, UK (#864)

* initial commit

* test cases added

* cherwell .md added

* update_docu_links run
This commit is contained in:
dt215git
2023-04-10 16:47:12 +01:00
committed by GitHub
parent 125167d2a9
commit 4de2cbe8fc
4 changed files with 101 additions and 1 deletions

View File

@@ -487,6 +487,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Cambridge City Council](/doc/source/cambridge_gov_uk.md) / cambridge.gov.uk
- [Canterbury City Council](/doc/source/canterbury_gov_uk.md) / canterbury.gov.uk
- [Central Bedfordshire Council](/doc/source/centralbedfordshire_gov_uk.md) / centralbedfordshire.gov.uk
- [Cherwell District Council](/doc/source/cherwell_gov_uk.md) / cherwell.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

View File

@@ -0,0 +1,68 @@
import re
import requests
from bs4 import BeautifulSoup
from datetime import datetime, timedelta
from waste_collection_schedule import Collection
TITLE = "Cherwell District Council"
DESCRIPTION = "Cherwell District Council North Oxfordshire, UK"
URL = "https://www.cherwell.gov.uk"
TEST_CASES = {
"Test_001": {"uprn": "100120758315"},
"Test_002": {"uprn": "100120780449"},
"Test_003": {"uprn": 100120777153},
}
HEADERS = {
"user-agent": "Mozilla/5.0",
}
REGEX = {
"DATES": r"([Green|Blue|Brown]+ Bin)",
"ORDINALS": r"(st|nd|rd|th)",
}
ICON_MAP = {
"GREEN BIN": "mdi:trash-can",
"BLUE BIN": "mdi:recycle",
"BROWN BIN": "mdi:leaf"
}
class Source:
def __init__(self, uprn):
self._uprn = str(uprn).zfill(12)
def fetch(self):
today = datetime.now()
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
yr = int(today.year)
s = requests.Session()
r = s.get(f"https://www.cherwell.gov.uk/homepage/129/?uprn={self._uprn}",headers=HEADERS)
soup = BeautifulSoup(r.text, "html.parser")
boxes = soup.findAll("div", {"class": "boxed"})
entries = []
for box in boxes:
title = box.find("h3", {"class": "bin-collection-tasks__heading"}).text.replace("Your next ", "").replace(" collection", "")
# Get date, append year, and increment year if date is >1 month in the past.
# This tries to deal year-end dates when the YEAR is missing
date = box.find("p", {"class": "bin-collection-tasks__date"}).text.strip()
date += " " + str(yr)
dt = re.sub(REGEX["ORDINALS"],"", date)
dt = datetime.strptime(dt, "%d %B %Y")
if (dt - today) < timedelta(days=-31):
dt = dt.replace(year = dt.year + 1)
entries.append(
Collection(
date=dt.date(),
t=title,
icon=ICON_MAP.get(title.upper()),
)
)
return entries

View File

@@ -0,0 +1,31 @@
# Cherwell District Council
Support for schedules provided by [Cherwell District Council](https://www.cherwell.gov.uk/info/10/rubbish-and-recycling), serving Cherwell District Council, North Oxfordshire, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: cherwell_gov_uk
args:
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER
```
### Configuration Variables
**uprn**
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: cherwell_gov_uk
args:
uprn: "100120758315"
```
## How to find your `UPRN`
An easy way to find your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering your address details.

View File

@@ -30,7 +30,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Slovenia | Moji odpadki, Ljubljana |
| Sweden | Affärsverken, Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Region Gotland, Ronneby Miljöteknik, Samverkan Återvinning Miljö (SÅM), SRV Återvinning, SSAM, Sysav Sophämntning, Uppsala Vatten och Avfall AB, 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 | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
| United States of America | City of Oklahoma City, City of Pittsburgh, Republic Services, Seattle Public Utilities |
<!--End of country section-->