mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
implemented tmbc_gov_uk
This commit is contained in:
@@ -198,8 +198,8 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Landkreis Rotenburg (Wümme)](/doc/source/abfall_io.md) / lk-awr.de
|
||||
- [Landkreis Roth](/doc/source/c_trace_de.md) / landratsamt-roth.de
|
||||
- [Landkreis Schweinfurt](/doc/source/awido_de.md) / landkreis-schweinfurt.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
|
||||
- [Landkreis Sigmaringen](/doc/source/abfall_io.md) / landkreis-sigmaringen.de
|
||||
- [Landkreis Südliche Weinstraße](/doc/source/awido_de.md) / suedliche-weinstrasse.de
|
||||
- [Landkreis Tirschenreuth](/doc/source/awido_de.md) / kreis-tir.de
|
||||
@@ -485,6 +485,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Telford and Wrekin Council](/doc/source/telford_gov_uk.md) / telford.gov.uk
|
||||
- [Tewkesbury Borough Council](/doc/source/tewkesbury_gov_uk.md) / tewkesbury.gov.uk
|
||||
- [The Royal Borough of Kingston Council](/doc/source/kingston_gov_uk.md) / kingston.gov.uk
|
||||
- [Tonbridge and Malling Borough Council](/doc/source/tmbc_gov_uk.md) / tmbc.gov.uk
|
||||
- [Uttlesford District Council](/doc/source/uttlesford_gov_uk.md) / uttlesford.gov.uk
|
||||
- [Vale of White Horse District Council](/doc/source/binzone_uk.md) / whitehorsedc.gov.uk
|
||||
- [Walsall Council](/doc/source/walsall_gov_uk.md) / walsall.gov.uk
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from dateutil import parser
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
# mostly copied from braintree_gov_uk
|
||||
|
||||
TITLE = "Tonbridge and Malling Borough Council"
|
||||
DESCRIPTION = "Tonbridge and Malling Borough Council, UK - Waste Collection"
|
||||
URL = "https://www.tmbc.gov.uk"
|
||||
TEST_CASES = {
|
||||
"High Street, West Malling": {"address": "138 High Street", "post_code": "ME19 6NE"},
|
||||
"Nutfields, Ightham, Sevenoaks": {"address": "5 Nutfields, Ightham, Sevenoaks", "post_code": "TN15 9EA"},
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"Black domestic waste": "mdi:trash-can",
|
||||
"Green recycling": "mdi:recycle",
|
||||
"Brown garden waste": "mdi:leaf",
|
||||
"Food waste": "mdi:food-apple",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, post_code: str, address: str):
|
||||
self.post_code = post_code
|
||||
self.address = address
|
||||
self.url = f"{URL}/xfp/form/167"
|
||||
self.form_data = {
|
||||
"q752eec300b2ffef2757e4536b77b07061842041a_0_0": (None, post_code),
|
||||
"page": (None, 128),
|
||||
}
|
||||
|
||||
def fetch(self):
|
||||
address_lookup = requests.post(
|
||||
"https://www.tmbc.gov.uk/xfp/form/167", files=self.form_data
|
||||
)
|
||||
address_lookup.raise_for_status()
|
||||
addresses = {}
|
||||
for address in BeautifulSoup(address_lookup.text, "html.parser").find_all(
|
||||
"option"
|
||||
):
|
||||
if not "..." in address["value"]:
|
||||
addresses[address["value"]] = address.text.strip()
|
||||
id = [
|
||||
address
|
||||
for address in addresses
|
||||
if addresses[address].startswith(self.address)]
|
||||
if len(id) == 0:
|
||||
raise Exception("Address not found")
|
||||
if len(id) > 1:
|
||||
raise Exception("Address is not unique")
|
||||
id = id[0]
|
||||
|
||||
|
||||
self.form_data["q752eec300b2ffef2757e4536b77b07061842041a_1_0"] = (
|
||||
None, id)
|
||||
self.form_data["next"] = (None, "Next")
|
||||
collection_lookup = requests.post(
|
||||
"https://www.tmbc.gov.uk/xfp/form/167", files=self.form_data
|
||||
)
|
||||
collection_lookup.raise_for_status()
|
||||
entries = []
|
||||
for rows in BeautifulSoup(collection_lookup.text, "html.parser").find(
|
||||
"table", class_="waste-collections-table"
|
||||
).find("tbody").find_all("tr"):
|
||||
date_td = rows.find_all("td")[0]
|
||||
bins_td = rows.find_all("td")[1]
|
||||
|
||||
date = parser.parse(date_td.text.strip(), dayfirst=True).date()
|
||||
for bin in bins_td.find("div", class_="collections").findAll("p"):
|
||||
bin = bin.text.strip()
|
||||
entries.append(
|
||||
Collection(
|
||||
date=date,
|
||||
t=bin,
|
||||
icon=ICON_MAP.get(bin),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
37
doc/source/tmbc_gov_uk.md
Normal file
37
doc/source/tmbc_gov_uk.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Braintree District Council
|
||||
|
||||
Support for schedules provided by [Tonbridge and Malling Borough Council](https://www.tmbc.gov.uk/xfp/form/167), serving Tonbridge and Malling, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: tmbc_gov_uk
|
||||
args:
|
||||
post_code: Post Code
|
||||
address: Address
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**post_code**
|
||||
*(string) (required)*
|
||||
|
||||
**address**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: tmbc_gov_uk
|
||||
args:
|
||||
post_code: "ME19 6NE"
|
||||
address: "138 High Street"
|
||||
```
|
||||
|
||||
## How to verify that your address works
|
||||
|
||||
Visit [tmbc.gov.uk](https://www.tmbc.gov.uk/xfp/form/167) page and search for your address. The string you select as Address (only starts with is checked, so you can stop after the street) should match exactly your address parameter.
|
||||
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 | 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, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, 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, 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, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough 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, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, 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, 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, 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, Wigan Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
<!--End of country section-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user