mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Basildon gov uk (#886)
* adding basildon gov uk * Updated Docs for Basildon Council * Corrected Basildon Council Naming * Tweaks to code * adding test case in py and empty last line in md
This commit is contained in:
@@ -483,6 +483,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
|
||||
- [Amber Valley Borough Council](/doc/source/ambervalley_gov_uk.md) / ambervalley.gov.uk
|
||||
- [Ashfield District Council](/doc/source/ashfield_gov_uk.md) / ashfield.gov.uk
|
||||
- [Basildon Council](/doc/source/basildon_gov_uk.md) / basildon.gov.uk
|
||||
- [Basingstoke and Deane Borough Council](/doc/source/basingstoke_gov_uk.md) / basingstoke.gov.uk
|
||||
- [Binzone](/doc/source/binzone_uk.md) / southoxon.gov.uk
|
||||
- [Blackburn with Darwen Borough Council](/doc/source/blackburn_gov_uk.md) / blackburn.gov.uk
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import requests
|
||||
import bs4
|
||||
import re
|
||||
|
||||
from datetime import datetime
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Basildon Council"
|
||||
DESCRIPTION = "Source for basildon.gov.uk services for Basildon Council, UK."
|
||||
URL = "https://basildon.gov.uk"
|
||||
TEST_CASES = {
|
||||
"Test_001": {"postcode": "CM111BJ", "address": "6, HEADLEY ROAD"},
|
||||
"Test_002": {"postcode": "SS14 1QU", "address": "25, LONG RIDING"}
|
||||
}
|
||||
HEADERS = {
|
||||
"user-agent": "Mozilla/5.0",
|
||||
}
|
||||
ICON_MAP = {
|
||||
"DryNext": "mdi:recycle",
|
||||
"GlassNext": "mdi:glass-fragile",
|
||||
"RubbishNext": "mdi:trash-can",
|
||||
"GardenAndFoodNext": "mdi:leaf",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, postcode, address):
|
||||
self._postcode = postcode
|
||||
self._address = address
|
||||
|
||||
def fetch(self):
|
||||
|
||||
s = requests.Session()
|
||||
|
||||
data = {
|
||||
"__Click": "$Refresh",
|
||||
"txtPostcode": self._postcode,
|
||||
"txtAddress": self._address
|
||||
}
|
||||
schedule_request = s.post(
|
||||
f"https://www3.basildon.gov.uk/website2/postcodes.nsf/frmMyBasildon",
|
||||
headers=HEADERS,
|
||||
data=data
|
||||
)
|
||||
html_rowdata = schedule_request.content
|
||||
rowdata = bs4.BeautifulSoup(html_rowdata, "html.parser")
|
||||
|
||||
# Extract bin types and next collection dates
|
||||
entries = []
|
||||
for bintype in ICON_MAP:
|
||||
for i in range(1,7):
|
||||
bintype_date = rowdata.find('input', {'name': f'{bintype}{i}'})
|
||||
if bintype_date:
|
||||
date_str = bintype_date['value']
|
||||
date_str = re.sub(r'\b(\d+)(st|nd|rd|th)\b', r'\1', date_str)
|
||||
entries.append(
|
||||
Collection(
|
||||
t=bintype.replace("Next",""),
|
||||
date=datetime.strptime(date_str, "%a, %d %b %Y").date(),
|
||||
icon=ICON_MAP.get(bintype)
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
36
doc/source/basildon_gov_uk.md
Normal file
36
doc/source/basildon_gov_uk.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Basildon Council
|
||||
|
||||
Support for schedules provided by [Basildon Council](https://www3.basildon.gov.uk/website2/postcodes.nsf/frmMyBasildon), UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: basildon_gov_uk
|
||||
args:
|
||||
postcode: POSTCODE
|
||||
address: FIRST LINE OF ADDRESS (X, STREET NAME)
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**postcode**
|
||||
*(string) (required)*
|
||||
**address**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: basildon_gov_uk
|
||||
args:
|
||||
postcode: CM111BJ
|
||||
address: 6, HEADLEY ROAD
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
An easy way to discover your Postcode and address used by this service is by going to <https://www3.basildon.gov.uk/website2/postcodes.nsf/frmMyBasildon> and entering in your address details.
|
||||
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, 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, 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 Bexley, 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, Basildon 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 Bexley, 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-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user