Skip to content

Commit

Permalink
feat: Adding Warrington Borough Council
Browse files Browse the repository at this point in the history
fix: #695
  • Loading branch information
m26dvd committed Nov 11, 2024
1 parent 9d208e8 commit 07fdde6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
7 changes: 7 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,13 @@
"wiki_name": "Waltham Forest",
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"WarringtonBoroughCouncil": {
"url": "https://www.warrington.gov.uk",
"wiki_command_url_override": "https://www.warrington.gov.uk",
"uprn": "10094964379",
"wiki_name": "Warrington Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"WarwickDistrictCouncil": {
"url": "https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/100070263793",
"wiki_command_url_override": "https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/XXXXXXXX",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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": []}

URI = f"https://www.warrington.gov.uk/bin-collections/get-jobs/{user_uprn}"

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

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

# Loop through each collection in bin_collection
for collection in bin_collection["schedule"]:
bin_type = collection["Name"]
collection_dates = collection["ScheduledStart"]

print(f"Bin Type: {bin_type}")
print(f"Collection Date: {collection_dates}")

dict_data = {
"type": bin_type,
"collectionDate": datetime.strptime(
collection_dates,
"%Y-%m-%dT%H:%M:%S",
).strftime(date_format),
}
bindata["bins"].append(dict_data)

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

return bindata
12 changes: 12 additions & 0 deletions wiki/Councils.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ This document is still a work in progress, don't worry if your council isn't lis
- [Wakefield City Council](#wakefield-city-council)
- [Walsall Council](#walsall-council)
- [Waltham Forest](#waltham-forest)
- [Warrington Borough Council](#warrington-borough-council)
- [Warwick District Council](#warwick-district-council)
- [Watford Borough Council](#watford-borough-council)
- [Waverley Borough Council](#waverley-borough-council)
Expand Down Expand Up @@ -2809,6 +2810,17 @@ Note: Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your U

---

### Warrington Borough Council
```commandline
python collect_data.py WarringtonBoroughCouncil https://www.warrington.gov.uk -u XXXXXXXX
```
Additional parameters:
- `-u` - UPRN

Note: You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.

---

### Warwick District Council
```commandline
python collect_data.py WarwickDistrictCouncil https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/XXXXXXXX
Expand Down

0 comments on commit 07fdde6

Please sign in to comment.