mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 00:04:11 +01:00
Fix: Exeter Council (#1151)
* regex updated * reformatting + typo fix (@5ila5)
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Exeter City Council"
|
||||
DESCRIPTION = "Source for Exeter City services for Exeter City Council, UK."
|
||||
URL = "https://exeter.gov.uk/"
|
||||
TEST_CASES = {
|
||||
"Test_001": {"uprn": "10013049539"},
|
||||
"Test_001": {"uprn": "100040227486"},
|
||||
"Test_002": {"uprn": "10013043921"},
|
||||
"Test_003": {"uprn": 10023120282},
|
||||
"Test_004": {"uprn": 100040241022},
|
||||
@@ -19,9 +19,10 @@ ICON_MAP = {
|
||||
"REFUSE": "mdi:trash-can",
|
||||
"RECYCLING": "mdi:recycle",
|
||||
"GARDEN WASTE": "mdi:leaf",
|
||||
"FOOD WASTE": "mdi:food"
|
||||
"FOOD WASTE": "mdi:food",
|
||||
}
|
||||
REGEX_ORDINALS = r"(st|nd|rd|th) "
|
||||
REGEX_ORDINALS = r"\d(st|nd|rd|th) "
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn):
|
||||
@@ -30,7 +31,9 @@ class Source:
|
||||
def fetch(self):
|
||||
|
||||
s = requests.Session()
|
||||
r = s.get(f"https://exeter.gov.uk/repositories/hidden-pages/address-finder/?qsource=UPRN&qtype=bins&term={self._uprn}")
|
||||
r = s.get(
|
||||
f"https://exeter.gov.uk/repositories/hidden-pages/address-finder/?qsource=UPRN&qtype=bins&term={self._uprn}"
|
||||
)
|
||||
|
||||
json_data = json.loads(r.text)[0]["Results"]
|
||||
soup = BeautifulSoup(json_data, "html.parser")
|
||||
@@ -41,11 +44,12 @@ class Source:
|
||||
for (b, d) in zip(bins, dates):
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(re.compile(REGEX_ORDINALS).sub("",d.text),"%A, %d%B %Y").date(),
|
||||
date=datetime.strptime(
|
||||
re.compile(REGEX_ORDINALS).sub("", d.text), "%A, %d%B %Y"
|
||||
).date(),
|
||||
t=b.text.replace(" collection", ""),
|
||||
icon=ICON_MAP.get(b.text.replace(" collection", "").upper()),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
return entries
|
||||
|
||||
@@ -30,7 +30,7 @@ waste_collection_schedule:
|
||||
|
||||
## How to find your UPRN
|
||||
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by looking at the url of you collection schedule on the Exeter City Council website. The set of numbers at teh end of the url are your uprn.
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by looking at the url of you collection schedule on the Exeter City Council website. The set of numbers at the end of the url are your uprn.
|
||||
|
||||
For example:
|
||||
_exeter.gov.uk/bins-and-recycling/bin-collections/when-is-my-bin-collected/?UPRN=`10013049539`_
|
||||
|
||||
Reference in New Issue
Block a user