Added Horsham District Council

This commit is contained in:
Colin Barker
2023-01-04 17:12:51 +00:00
parent 2fbb34dd62
commit bb4d5c8791
4 changed files with 92 additions and 1 deletions

View File

@@ -279,6 +279,7 @@ Waste collection schedules in the following formats and countries are supported.
- [FCC Environment](/doc/source/fccenvironment_co_uk.md) / fccenvironment.co.uk
- [Guildford Borough Council](/doc/source/guildford_gov_uk.md) / guildford.gov.uk
- [Harborough District Council](/doc/source/fccenvironment_co_uk.md) / harborough.gov.uk
- [Horsham District Council](/doc/source/horsham_gov_uk.md) / horsham.gov.uk
- [Huntingdonshire District Council](/doc/source/huntingdonshire_gov_uk.md) / huntingdonshire.gov.uk
- [Lewes District Council](/doc/source/environmentfirst_co_uk.md) / lewes-eastbourne.gov.uk
- [London Borough of Lewisham](/doc/source/lewisham_gov_uk.md) / lewisham.gov.uk

View File

@@ -0,0 +1,58 @@
import logging
from datetime import datetime
from waste_collection_schedule import Collection
import requests
from bs4 import BeautifulSoup
TITLE = "Horsham District Council"
DESCRIPTION = "Source script for Horsham District Council"
URL = "https://www.horsham.gov.uk"
TEST_CASES = {
"Blackthorn Avenue - number": {"uprn": 10013792881},
"Blackthorn Avenue - string": {"uprn": "10013792881"}
}
API_URL = "https://satellite.horsham.gov.uk/environment/refuse/cal_details.asp"
ICON_MAP = {
"Refuse Bin for Non-Recycling": "mdi:trash-can",
"Blue-Top Bin for Recycling": "mdi:recycle",
"Brown-Top Bin for Garden Waste": "mdi:leaf",
}
HEADERS = {
"user-agent": "Mozilla/5.0",
}
_LOGGER = logging.getLogger(__name__)
class Source:
def __init__(self, uprn: str):
self._uprn = str(uprn)
def fetch(self):
entries = []
r = requests.post(
API_URL,
data={"uprn": self._uprn},
)
soup = BeautifulSoup(r.text, features="html.parser")
results = soup.find_all("tr")
for result in results:
result_row = result.find_all("td")
if len(result_row) == 0: # This removes the first header row, or any rows with no data
continue
else:
date = datetime.strptime(result_row[1].text, "%d/%m/%Y").date() # Pull out the rows date
collection_text = result_row[2].text.replace(u'\xa0', u' ') # This is to remove a non-blanking space
collection_items = collection_text.split("AND") # Sometimes there will be multiple bins, split with the word AND
for collection_type in collection_items:
entries.append(
Collection(
date=date,
t=collection_type.strip(), # Strip added to remove trailing white space
icon=ICON_MAP[collection_type.strip()] # Strip added to remove trailing white space
)
)
return entries

View File

@@ -0,0 +1,32 @@
# Horsham District Council
Support for schedules provided by [Horsham District Council](https://www.horsham.gov.uk/waste-recycling-and-bins/household-bin-collections/check-your-bin-collection-day).
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: horsham_gov_uk
args:
uprn: UPRN_CODE
```
### Configuration Variables
**uprn**
_(string) (required)_
## Example using UPRN
```yaml
waste_collection_schedule:
sources:
- name: horsham_gov_uk
args:
uprn: "10013792881"
```
## How to get the source argument
An easy way to find your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.

View File

@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Poland | Ecoharmonogram, Warsaw |
| Sweden | 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, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, 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, Cheshire East Council, Chesterfield Borough Council, City of York Council, Colchester Borough Council, Cornwall Council, Derby City Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle 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, Stevenage Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council |
| United Kingdom | Ashfield District Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Cheshire East Council, Chesterfield Borough Council, City of York Council, Colchester Borough Council, Cornwall Council, Derby City Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Guildford Borough Council, Harborough District Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Manchester City Council, Middlesbrough Council, Newcastle 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, Stevenage Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council |
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
<!--End of country section-->