Skip to content

Commit

Permalink
feat: Adding Exeter City Council
Browse files Browse the repository at this point in the history
fix: #1017
  • Loading branch information
m26dvd committed Nov 17, 2024
1 parent 9a43be0 commit 1ea3acf
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
6 changes: 6 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@
"wiki_name": "Erewash Borough Council",
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"ExeterCityCouncil": {
"uprn": "100040212270",
"url": "https://www.exeter.gov.uk",
"wiki_name": "Exeter City Council",
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"FalkirkCouncil": {
"url": "https://www.falkirk.gov.uk",
"wiki_command_url_override": "https://www.falkirk.gov.uk",
Expand Down
52 changes: 52 additions & 0 deletions uk_bin_collection/uk_bin_collection/councils/ExeterCityCouncil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import time

import requests
from bs4 import BeautifulSoup

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://exeter.gov.uk/repositories/hidden-pages/address-finder/?qsource=UPRN&qtype=bins&term={user_uprn}"

response = requests.get(URI)
response.raise_for_status()

data = response.json()

soup = BeautifulSoup(data[0]["Results"], "html.parser")
soup.prettify()

# Extract bin schedule
for section in soup.find_all("h2"):
bin_type = section.text.strip()
collection_date = section.find_next("h3").text.strip()

dict_data = {
"type": bin_type,
"collectionDate": datetime.strptime(
remove_ordinal_indicator_from_date_string(collection_date),
"%A, %d %B %Y",
).strftime(date_format),
}
bindata["bins"].append(dict_data)

bindata["bins"].sort(
key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
)

return bindata
12 changes: 12 additions & 0 deletions wiki/Councils.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ This document is still a work in progress, don't worry if your council isn't lis
- [Environment First](#environment-first)
- [Epping Forest District Council](#epping-forest-district-council)
- [Erewash Borough Council](#erewash-borough-council)
- [Exeter City Council](#exeter-city-council)
- [Falkirk Council](#falkirk-council)
- [Fareham Borough Council](#fareham-borough-council)
- [Fenland District Council](#fenland-district-council)
Expand Down Expand Up @@ -1272,6 +1273,17 @@ Note: Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyadd

---

### Exeter City Council
```commandline
python collect_data.py ExeterCityCouncil https://www.exeter.gov.uk -u XXXXXXXX
```
Additional parameters:
- `-u` - UPRN

Note: Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search).

---

### Falkirk Council
```commandline
python collect_data.py FalkirkCouncil https://www.falkirk.gov.uk -u XXXXXXXX
Expand Down

0 comments on commit 1ea3acf

Please sign in to comment.