Skip to content

Commit

Permalink
Merge pull request #597 from stuartmacd/feat-add-stAlbans
Browse files Browse the repository at this point in the history
feat: Add Scraper for St Albans City and District Council
  • Loading branch information
robbrad authored Jan 28, 2024
2 parents a48384b + 94c1a38 commit 050e03d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ Feature: Test each council output matches expected results
| council | selenium_url | selenium_mode |
| SouthTynesideCouncil | None | None |

@StAlbansCityAndDistrictCouncil
Examples: StAlbansCityAndDistrictCouncil
| council | selenium_url | selenium_mode |
| StAlbansCityAndDistrictCouncil | None | None |

@StaffordshireMoorlandsDistrictCouncil
Examples: StaffordshireMoorlandsDistrictCouncil
| council | selenium_url | selenium_mode |
Expand Down
6 changes: 6 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,12 @@
"wiki_name": "Staffordshire Moorlands District Council",
"wiki_note": "To get the UPRN, you can use [FindMyAddress](https://www.findmyaddress.co.uk/search)"
},
"StAlbansCityAndDistrictCouncil": {
"skip_get_url": true,
"uprn": "100081153583",
"url": "https://gis.stalbans.gov.uk/NoticeBoard9/VeoliaProxy.NoticeBoard.asmx/GetServicesByUprnAndNoticeBoard",
"wiki_name": "St Albans City and District Council"
},
"StockportBoroughCouncil": {
"url": "https://myaccount.stockport.gov.uk/bin-collections/show/100011434401",
"wiki_command_url_override": "https://myaccount.stockport.gov.uk/bin-collections/show/XXXXXXXX",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
from dateutil import parser


class CouncilClass(AbstractGetBinDataClass):
def parse_data(self, page: str, **kwargs) -> dict:
user_uprn = kwargs.get("uprn")
check_uprn(user_uprn)

data = {
"bins": []
}

headers = {
"Content-Type": "application/json; charset=UTF-8",
}

req_data = {
"uprn": user_uprn,
"noticeBoard": "default"
}

url = "https://gis.stalbans.gov.uk/NoticeBoard9/VeoliaProxy.NoticeBoard.asmx/GetServicesByUprnAndNoticeBoard"

response = requests.post(url, json=req_data, headers=headers)

collections_response = response.json()

collections = []

for collection in collections_response["d"]:
collection_data = collection["ServiceHeaders"][0]
bin_type = collection_data["TaskType"]
collection_date = collection_data["Next"]
next_collection = parser.isoparser().isoparse(collection_date)
collections.append((bin_type, next_collection))

ordered_data = sorted(collections, key=lambda x: x[1])

for item in ordered_data:
dict_data = {
"type": item[0],
"collectionDate": item[1].strftime(date_format),
}
data["bins"].append(dict_data)

return data

0 comments on commit 050e03d

Please sign in to comment.