mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Merge pull request #256 from mampfes/revert-250-gh/wakefield_gov_uk
Revert "[feat] Add Wakefield Council"
This commit is contained in:
@@ -151,7 +151,6 @@ Currently the following service providers are supported:
|
||||
- [Peterborough City Council - peterborough.gov.uk](./doc/source/peterborough_gov_uk.md)
|
||||
- [South Cambridgeshire District Council - scambs.gov.uk](./doc/source/scambs_gov_uk.md)
|
||||
- [City of York Council - york.gov.uk](./doc/source/york_gov_uk.md)
|
||||
- [Wakefield Council - wakefield.gov.uk](./doc/source/wakefield_gov_uk.md)
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "wakefield.gov.uk"
|
||||
DESCRIPTION = (
|
||||
"Source for wakefield.gov.uk services for Wakefield"
|
||||
)
|
||||
URL = "wakefield.gov.uk"
|
||||
TEST_CASES = {
|
||||
"houseUPRN" : {"uprn": "63161064"},
|
||||
}
|
||||
|
||||
API_URLS = {
|
||||
"collection": "https://www.wakefield.gov.uk/site/Where-I-Live-Results?uprn={}",
|
||||
}
|
||||
|
||||
ICONS = {
|
||||
"Household waste": "mdi:trash-can",
|
||||
"Mixed recycling": "mdi:recycle",
|
||||
"Garden waste recycling": "mdi:leaf",
|
||||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn=None, postcode=None):
|
||||
self._uprn = uprn
|
||||
|
||||
def fetch(self):
|
||||
user_agent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64)"
|
||||
headers = {"User-Agent": user_agent}
|
||||
|
||||
responseContent=None
|
||||
r = requests.get(f"https://www.wakefield.gov.uk/site/Where-I-Live-Results?uprn={self._uprn}", headers)
|
||||
responseContent = r.text
|
||||
|
||||
soup = BeautifulSoup(responseContent, features="html.parser")
|
||||
entries = []
|
||||
|
||||
#Full Credit to Rob Bradley for this: https://github.com/robbrad/UKBinCollectionData/blob/master/outputs/WakefieldCityCouncil.json
|
||||
|
||||
for bins in soup.findAll(
|
||||
"div", {"class": lambda L: L and L.startswith("mb10 ind-waste-")}
|
||||
):
|
||||
|
||||
# Get the type of bin
|
||||
bin_types = bins.find_all("div", {"class": "mb10"})
|
||||
bin_type = bin_types[0].get_text(strip=True)
|
||||
|
||||
# Find the collection dates
|
||||
binCollections = bins.find_all(
|
||||
"div", {"class": lambda L: L and L.startswith("col-sm-4")}
|
||||
)
|
||||
|
||||
if binCollections:
|
||||
lastCollections = binCollections[0].find_all("div")
|
||||
nextCollections = binCollections[1].find_all("div")
|
||||
|
||||
# Get the collection date
|
||||
lastCollection = lastCollections[1].get_text(strip=True)
|
||||
nextCollection = nextCollections[1].get_text(strip=True)
|
||||
|
||||
if lastCollection:
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(
|
||||
nextCollection, "%d/%m/%Y"
|
||||
).date(),
|
||||
t=bin_type,
|
||||
icon=ICONS.get(bin_type)
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Wakefield Council
|
||||
|
||||
Support for schedules provided by [Wakefield Council](https://www.wakefield.gov.uk/site/Where-I-Live-Results), serving the borough of Wakefield, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: wakefield_gov_uk
|
||||
args:
|
||||
uprn: UPRN
|
||||
```
|
||||
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**<br>
|
||||
*(string) (required)*
|
||||
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: wakefield_gov_uk
|
||||
args:
|
||||
uprn: 63161064
|
||||
```
|
||||
1
info.md
1
info.md
@@ -138,4 +138,3 @@ Currently the following service providers are supported:
|
||||
- [Peterborough City Council - peterborough.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/peterborough_gov_uk.md)
|
||||
- [South Cambridgeshire District Council - scambs.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/scambs_gov_uk.md)
|
||||
- [City of York Council - york.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/york_gov_uk.md)
|
||||
- [Wakefield Council - wakefield.gov.uk](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/wakefield_gov_uk.md)
|
||||
|
||||
Reference in New Issue
Block a user