Skip to content

Commit

Permalink
update strptime to account for new response text (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
dt215git authored Oct 24, 2023
1 parent dd9ec4d commit 02cd892
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import json
from datetime import datetime

import requests
import json
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection # type: ignore[attr-defined]

TITLE = "North Lincolnshire Council"
DESCRIPTION = "Source for northlincs.gov.uk services for North Lincolnshire Council, UK."
DESCRIPTION = (
"Source for northlincs.gov.uk services for North Lincolnshire Council, UK."
)
URL = "https://www.northlincs.gov.uk"
TEST_CASES = {
"Test_001": {"uprn": "100050200824"},
Expand All @@ -29,21 +30,24 @@ def __init__(self, uprn):
self._uprn = str(uprn)

def fetch(self):
r = requests.get(f"https://m.northlincs.gov.uk/bin_collections?no_collections=20&uprn={self._uprn}")
r = requests.get(
f"https://m.northlincs.gov.uk/bin_collections?no_collections=20&uprn={self._uprn}"
)
r.raise_for_status()
r_json = json.loads(r.content.decode('utf-8-sig'))["Collections"]
r_json = json.loads(r.content.decode("utf-8-sig"))["Collections"]

entries = []

for collection in r_json:
date = datetime.strptime(collection["CollectionDate"], "%Y-%m-%d").date()
date = datetime.strptime(
collection["CollectionDate"].split(" ")[0], "%Y-%m-%d"
).date()
waste_type = collection["BinCodeDescription"]
entries.append(
Collection(
date=date,
t=waste_type,
icon=ICON_MAP.get(waste_type),

)
)
return entries

0 comments on commit 02cd892

Please sign in to comment.