Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 2025 Council Pack 4 #1216

Merged
merged 22 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
986af3c
docs: Update Councils.md from input.json
actions-user Feb 4, 2025
256ae61
fix: Neath Port Talbot
m26dvd Feb 4, 2025
42c8665
fix: Torridge District Council
m26dvd Feb 4, 2025
c7efe69
feat: Adding Bolsover Council
m26dvd Feb 4, 2025
1b0bdcf
feat: Adding Amber Valley Borough Council
m26dvd Feb 5, 2025
32314e6
feat: Adding Redcar and Cleveland Council
m26dvd Feb 5, 2025
7b634d7
feat: Adding Epsom and Ewell Borough Council
m26dvd Feb 5, 2025
589af89
feat: Adding Cherwell District Council
m26dvd Feb 6, 2025
bb54c5d
feat: Adding Runnymede Borough Council
m26dvd Feb 6, 2025
fe2d8c0
Merge branch 'robbrad:master' into master
m26dvd Feb 11, 2025
e39093e
docs: Update Councils.md from input.json
actions-user Feb 11, 2025
86acabc
fix: Tendring District Council
m26dvd Feb 11, 2025
5054a03
Merge branch 'master' of https://github.com/m26dvd/UKBinCollectionData
m26dvd Feb 11, 2025
f203948
fix: Sunderland City Council
m26dvd Feb 11, 2025
9fe78a4
fix: Conwy County Borough
m26dvd Feb 11, 2025
c7ee80e
docs: Update Councils.md from input.json
actions-user Feb 11, 2025
f4890eb
fix: Derbyshire Dales District Council
m26dvd Feb 12, 2025
e7d85df
Merge branch 'master' of https://github.com/m26dvd/UKBinCollectionData
m26dvd Feb 12, 2025
4b98d8a
Merge branch 'robbrad:master' into master
m26dvd Feb 17, 2025
1838b23
docs: Update Councils.md from input.json
actions-user Feb 17, 2025
f1b558d
fix: Leeds City Council
m26dvd Feb 17, 2025
29bd623
fix: Cotswold District Council
m26dvd Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"wiki_name": "Adur and Worthing Councils",
"wiki_note": "Replace XXXXXXXX with your UPRN. You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find it."
},
"AmberValleyBoroughCouncil": {
"url": "https://ambervalley.gov.uk",
"uprn": "100030026621",
"wiki_name": "Amber Valley Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"AntrimAndNewtonabbeyCouncil": {
"url": "https://antrimandnewtownabbey.gov.uk/residents/bins-recycling/bins-schedule/?Id=643",
"wiki_command_url_override": "https://antrimandnewtownabbey.gov.uk/residents/bins-recycling/bins-schedule/?Id=XXXX",
Expand Down Expand Up @@ -197,6 +203,12 @@
"wiki_name": "Blaenau Gwent County Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"BolsoverCouncil": {
"url": "https://bolsover.gov.uk",
"uprn": "100030066827",
"wiki_name": "Bolsover Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"BoltonCouncil": {
"postcode": "BL1 5PQ",
"skip_get_url": true,
Expand Down Expand Up @@ -391,6 +403,12 @@
"wiki_name": "Cheltenham Borough Council",
"wiki_note": "Pass the UPRN. You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"CherwellDistrictCouncil": {
"uprn": "100121292407",
"url": "https://www.cherwell.gov.uk",
"wiki_name": "Cherwell District Council",
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"CheshireEastCouncil": {
"url": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=100012791226&onelineaddress=3%20COBBLERS%20YARD,%20SK9%207DZ&_=1689413260149",
"wiki_command_url_override": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=XXXXXXXX&onelineaddress=XXXXXXXX&_=1689413260149",
Expand Down Expand Up @@ -440,11 +458,10 @@
"wiki_note": "Pass the house name/number in the house number parameter, wrapped in double quotes."
},
"ConwyCountyBorough": {
"postcode": "LL30 2DF",
"uprn": "100100429249",
"url": "https://www.conwy.gov.uk/Contensis-Forms/erf/collection-result-soap-xmas.asp?ilangid=1&uprn=100100429249",
"url": "https://www.conwy.gov.uk",
"wiki_name": "Conwy County Borough Council",
"wiki_note": "Conwy County Borough Council uses a straight UPRN in the URL, e.g., `&uprn=XXXXXXXXXXXXX`."
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"CopelandBoroughCouncil": {
"uprn": "100110734613",
Expand Down Expand Up @@ -535,7 +552,6 @@
"skip_get_url": true,
"uprn": "10070102161",
"url": "https://www.derbyshiredales.gov.uk/",
"web_driver": "http://selenium:4444",
"wiki_name": "Derbyshire Dales District Council",
"wiki_note": "Pass the UPRN and postcode. To get the UPRN, you can use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
Expand Down Expand Up @@ -709,6 +725,12 @@
"wiki_name": "Epping Forest District Council",
"wiki_note": "Replace the postcode in the URL with your own."
},
"EpsomandEwellBoroughCouncil": {
"uprn": "100061349083",
"url": "https://www.epsom-ewell.gov.uk",
"wiki_name": "Epsom and Ewell Borough Council",
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"ErewashBoroughCouncil": {
"skip_get_url": true,
"uprn": "10003582028",
Expand Down Expand Up @@ -1457,6 +1479,14 @@
"wiki_name": "Reading Borough Council",
"wiki_note": "Replace XXXXXXXX with your property's UPRN."
},
"RedcarandClevelandCouncil": {
"house_number": "11",
"postcode": "TS10 2RE",
"skip_get_url": true,
"url": "https://www.redcar-cleveland.gov.uk",
"wiki_name": "Redcar and Cleveland Council",
"wiki_note": "Pass the house name/number and postcode in their respective parameters"
},
"RedditchBoroughCouncil": {
"uprn": "10094557691",
"url": "https://redditchbc.gov.uk",
Expand Down Expand Up @@ -1531,6 +1561,13 @@
"wiki_name": "Rugby Borough Council",
"wiki_note": "Provide your UPRN and postcode. You can find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"RunnymedeBoroughCouncil": {
"skip_get_url": true,
"uprn": "100061483636",
"url": "https://www.runnymede.gov.uk/",
"wiki_name": "Runnymede Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"RushcliffeBoroughCouncil": {
"postcode": "NG13 8TZ",
"skip_get_url": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from datetime import datetime

import requests

from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass


# import the wonderful Beautiful Soup and the URL grabber
class CouncilClass(AbstractGetBinDataClass):
"""
Concrete classes have to implement all abstract operations of the
base class. They can also override some operations with a default
implementation.
"""

def parse_data(self, page: str, **kwargs) -> dict:

user_uprn = kwargs.get("uprn")
check_uprn(user_uprn)
bindata = {"bins": []}

WASTE_TYPES_DATE_KEY = {
"REFUSE": "refuseNextDate",
"RECYCLING": "recyclingNextDate",
"GREEN": "greenNextDate",
"COMMUNAL REFUSE": "communalRefNextDate",
"COMMUNAL RECYCLING": "communalRycNextDate",
}

URI = f"https://info.ambervalley.gov.uk/WebServices/AVBCFeeds/WasteCollectionJSON.asmx/GetCollectionDetailsByUPRN?uprn={user_uprn}"

# Make the GET request
response = requests.get(URI)

# Parse the JSON response
bin_collection = response.json()

# print(bin_collection)

for bin, datge_key in WASTE_TYPES_DATE_KEY.items():
date_ = datetime.strptime(
bin_collection[datge_key], "%Y-%m-%dT%H:%M:%S"
).strftime(date_format)
if date_ == "01/01/1":
continue
elif date_ == "01/01/1900":
continue

dict_data = {
"type": bin,
"collectionDate": date_,
}
bindata["bins"].append(dict_data)

bindata["bins"].sort(
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
)

return bindata
Loading
Loading