mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 00:04:11 +01:00
add Sholland_gov_uk
This commit is contained in:
@@ -795,6 +795,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [South Derbyshire District Council](/doc/source/southderbyshire_gov_uk.md) / southderbyshire.gov.uk
|
||||
- [South Gloucestershire Council](/doc/source/southglos_gov_uk.md) / southglos.gov.uk
|
||||
- [South Hams District Council](/doc/source/fccenvironment_co_uk.md) / southhams.gov.uk
|
||||
- [South Holland District Council](/doc/source/sholland_gov_uk.md) / sholland.gov.uk
|
||||
- [South Norfolk Council](/doc/source/south_norfolk_and_broadland_gov_uk.md) / southnorfolkandbroadland.gov.uk
|
||||
- [South Oxfordshire District Council](/doc/source/binzone_uk.md) / southoxon.gov.uk
|
||||
- [South Tyneside Council](/doc/source/southtyneside_gov_uk.md) / southtyneside.gov.uk
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from bs4 import BeautifulSoup, Tag
|
||||
import datetime
|
||||
import re
|
||||
|
||||
TITLE = "South Holland District Council"
|
||||
DESCRIPTION = "Source for South Holland District Council."
|
||||
URL = "https://www.sholland.gov.uk/"
|
||||
TEST_CASES = {
|
||||
"10002546801": {
|
||||
"uprn": 10002546801,
|
||||
"postcode": "PE11 2FR",
|
||||
},
|
||||
"PE12 7AR": {
|
||||
"uprn": "100030897036",
|
||||
"postcode": "PE12 7AR",
|
||||
}
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"refuse": "mdi:trash-can",
|
||||
"garden": "mdi:leaf",
|
||||
"recycling": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://www.sholland.gov.uk/article/7156/Check-your-collection-days"
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn: str | int, postcode: str):
|
||||
self._uprn: str | int = str(uprn)
|
||||
self._postcode: str = postcode
|
||||
|
||||
|
||||
def fetch(self):
|
||||
args: dict[str, str|list] = {
|
||||
"SHDCWASTECOLLECTIONS_FORMACTION_NEXT": "SHDCWASTECOLLECTIONS_PAGE1_CONTINUEBUTTON",
|
||||
"SHDCWASTECOLLECTIONS_PAGE1_POSTCODENEW": self._postcode,
|
||||
"SHDCWASTECOLLECTIONS_PAGE1_BUILDING": "",
|
||||
"SHDCWASTECOLLECTIONS_PAGE1_ADDRESSLIST": ["", self._uprn]
|
||||
}
|
||||
s = requests.Session()
|
||||
|
||||
r = s.get(API_URL)
|
||||
r.raise_for_status()
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
|
||||
|
||||
form = soup.find("form", {"id": "SHDCWASTECOLLECTIONS_FORM"})
|
||||
if not form or not isinstance(form, Tag):
|
||||
raise Exception("Unable to find form")
|
||||
|
||||
request_url = form.attrs.get("action")
|
||||
hidden_values = form.find_all("input", {"type": "hidden"})
|
||||
|
||||
if not hidden_values:
|
||||
raise Exception("Unable to find hidden values")
|
||||
|
||||
for val in hidden_values:
|
||||
if not isinstance(val, Tag) or "SHDCWASTECOLLECTIONS_PAGE1_ADDRESSLIST" == str(val.attrs.get("name")):
|
||||
continue
|
||||
args[str(val.attrs.get("name"))] = str(val.attrs.get("value"))
|
||||
|
||||
|
||||
|
||||
|
||||
# get collection page
|
||||
r = requests.post(str(request_url), data=args)
|
||||
r.raise_for_status()
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
|
||||
|
||||
entries = []
|
||||
for d in soup.find_all("div", {"class": "nextcoll"}):
|
||||
if not isinstance(d, Tag):
|
||||
continue
|
||||
|
||||
collection_text = d.text.strip()
|
||||
|
||||
bin_type = collection_text.split(" ")[1]
|
||||
icon=ICON_MAP.get(bin_type.lower()) # Collection icon
|
||||
|
||||
splittet_text = collection_text.split(":")
|
||||
|
||||
dates_str = [splittet_text[1].split("(")[0]]
|
||||
if len(splittet_text) > 2:
|
||||
dates_str.append(splittet_text[2].split("(")[0])
|
||||
|
||||
for date_str in dates_str:
|
||||
date_str = date_str.replace("*", "").strip()
|
||||
date = datetime.datetime.strptime(re.sub(r'(\d)(st|nd|rd|th)', r'\1', date_str), "%A %d %B %Y").date()
|
||||
entries.append(Collection(date=date, t=bin_type,icon=icon))
|
||||
|
||||
return entries
|
||||
52
doc/source/sholland_gov_uk.md
Normal file
52
doc/source/sholland_gov_uk.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# South Holland District Council
|
||||
|
||||
Support for schedules provided by [South Holland District Council](https://www.sholland.gov.uk/), serving South Holland District Council, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sholland_gov_uk
|
||||
args:
|
||||
uprn: UPRN
|
||||
postcode: POSTCODE
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
**postcode**
|
||||
*(String) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sholland_gov_uk
|
||||
args:
|
||||
uprn: "10002546801"
|
||||
postcode: PE11 2FR
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Use your postcode as postcode argument
|
||||
|
||||
### How to get your UPRN
|
||||
|
||||
#### with findmyaddress.co.uk
|
||||
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by going to https://www.findmyaddress.co.uk/ and entering in your address details.
|
||||
|
||||
#### with browsers network analysis tab
|
||||
|
||||
- Got to <https://www.sholland.gov.uk/mycollections> and fill in postcode and select an address.
|
||||
- Open your browsers' developer tools (`right click -> inspect` / `F12`) and switch to the network tab.
|
||||
- Click Next. Select the first of the newly appeared requests (you might need to scroll up) and select the request tab of this request.
|
||||
- The second argument of `SHDCWASTECOLLECTIONS_PAGE1_ADDRESSLIST` should contain your UPRN
|
||||
2
info.md
2
info.md
@@ -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, 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, 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 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, 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, 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, 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 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-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user