adding rbwm_gov_uk (Windsor & Maidenhead) (#1093)

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
5ila5
2023-07-16 23:57:24 +02:00
committed by GitHub
parent 11433103cf
commit 616462a71d
4 changed files with 105 additions and 1 deletions

View File

@@ -829,6 +829,7 @@ Waste collection schedules in the following formats and countries are supported.
- [West Dunbartonshire Council](/doc/source/west_dunbartonshire_gov_uk.md) / west-dunbarton.gov.uk
- [Wigan Council](/doc/source/wigan_gov_uk.md) / wigan.gov.uk
- [Wiltshire Council](/doc/source/wiltshire_gov_uk.md) / wiltshire.gov.uk
- [Windsor and Maidenhead](/doc/source/rbwm_gov_uk.md) / my.rbwm.gov.uk
- [Wirral Council](/doc/source/wirral_gov_uk.md) / wirral.gov.uk
- [Wyre Forest District Council](/doc/source/wyreforestdc_gov_uk.md) / wyreforestdc.gov.uk
</details>

View File

@@ -0,0 +1,67 @@
from datetime import datetime
import requests
from bs4 import BeautifulSoup, NavigableString
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Windsor and Maidenhead"
DESCRIPTION = "Source for Windsor and Maidenhead."
URL = "https://my.rbwm.gov.uk/"
TEST_CASES = {
"Windsor 1": {"uprn": 100080381393},
"Windsor 2": {"uprn": "100080384194"},
"Maidenhead 1": {"uprn": "100080359672"},
"Maidenhead 2": {"uprn": 100080355442},
}
ICON_MAP = {
"refuse": "mdi:trash-can",
"garden waste": "mdi:leaf",
"recycling": "mdi:recycle",
}
API_URL = "https://my.rbwm.gov.uk/special/your-collection-dates"
class Source:
def __init__(self, uprn: str | int):
self._uprn: str = str(uprn).zfill(12)
def fetch(self):
s = requests.Session()
args = {
"uprn": self._uprn,
"subdate": datetime.now().strftime("%Y-%m-%d"),
}
# request needs to be made twice to get the correct response
r = s.get(API_URL, params=args)
r.raise_for_status()
r = s.get(API_URL, params=args)
r.raise_for_status()
soup = BeautifulSoup(r.text, "html.parser")
table = soup.find("table")
if not table or isinstance(table, NavigableString):
raise Exception("Invalid response from API")
entries = []
for tr in table.find_all("tr"):
tds = tr.find_all("td")
if len(tds) != 2:
continue
bi_type = tds[0].text.split("Collection Service")[0].strip()
date_string = tds[1].text.strip()
date = datetime.strptime(date_string, "%d/%m/%Y").date()
icon = ICON_MAP.get(bi_type.lower()) # Collection icon
entries.append(Collection(date=date, t=bi_type, icon=icon))
return entries

36
doc/source/rbwm_gov_uk.md Normal file
View File

@@ -0,0 +1,36 @@
# Windsor and Maidenhead
Support for schedules provided by [Windsor and Maidenhead](https://my.rbwm.gov.uk/), serving Windsor and Maidenhead, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: rbwm_gov_uk
args:
uprn: "UPRN"
```
### Configuration Variables
**uprn**
*(String | Integer) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: rbwm_gov_uk
args:
uprn: "100080381393"
```
## How to find your
Go to [https://my.rbwm.gov.uk/special/find-your-collection-dates](https://my.rbwm.gov.uk/special/find-your-collection-dates) and search for your address. When you see your upcoming collections your address bar should look something like this: `https://my.rbwm.gov.uk/special/your-collection-dates?uprn=100080381393&subdate=2023-07-16&addr=104%20St%20Andrews%20Crescent%20Windsor%20SL4%204EN`. The first argument (after `uprn=`) is your UPRN (`100080381393` in this example)
Another way to discover your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.

View File

@@ -31,7 +31,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, Real Luzern, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
| United Kingdom | Aberdeenshire Council, Amber Valley Borough Council, Ashfield District Council, Ashford Borough Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough 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, Croydon Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, Kirklees Council, Leicester City Council, Lewes District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, 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 Kesteven District Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Holland District Council, South Norfolk Council, South Oxfordshire District Council, South Tyneside 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, Warrington Borough Council, Waverley Borough Council, Wealden District Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wirral Council, Wyre Forest District Council |
| United Kingdom | Aberdeenshire Council, Amber Valley Borough Council, Ashfield District Council, Ashford Borough Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Broadland District Council, Broxtowe Borough 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, Croydon Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, East Riding of Yorkshire Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Highland, Horsham District Council, Huntingdonshire District Council, Kirklees Council, Leicester City Council, Lewes District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maidstone Borough Council, 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 Kesteven District Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Holland District Council, South Norfolk Council, South Oxfordshire District Council, South Tyneside 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, Warrington Borough Council, Waverley Borough Council, Wealden District Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Wyre Forest District Council |
| United States of America | Albuquerque, New Mexico, USA, City of Oklahoma City, City of Pittsburgh, Louisville, Kentucky, USA, Newark, Delaware, USA, Olympia, Washington, USA, ReCollect, Recycle Coach, Republic Services, Seattle Public Utilities, Tucson, Arizona, USA |
<!--End of country section-->