Skip to content

Commit

Permalink
Merge pull request #385 from edmondcck/salford_council_fix
Browse files Browse the repository at this point in the history
fix: Fix the incorrect key collectionTime in json output of Salford Council
  • Loading branch information
OliverCullimore authored Oct 24, 2023
2 parents 8c28287 + 83ad305 commit 9e5a1d5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ def parse_data(self, page: str, **kwargs) -> dict:
# Loop through each <li> tag in the <ul> tag to extract the collection date
for li in bin_list.find_all("li"):
# Convert the collection time to a datetime object
collection_time = datetime.strptime(li.text, "%A %d %B %Y")
collection_date = datetime.strptime(li.text, "%A %d %B %Y")

# Add the bin to the data dict
data["bins"].append(
{
# remove the ":" from the end of the bin type
"type": bin_type[:-1],
"collectionTime": collection_time,
"collectionDate": collection_date,
}
)

# Sort the bins by collection time
data["bins"] = sorted(data["bins"], key=lambda x: x["collectionTime"])
data["bins"] = sorted(data["bins"], key=lambda x: x["collectionDate"])

# Convert the datetime objects to strings in the desired format
for bin in data["bins"]:
bin["collectionTime"] = bin["collectionTime"].strftime(date_format)
bin["collectionDate"] = bin["collectionDate"].strftime(date_format)

return data

0 comments on commit 9e5a1d5

Please sign in to comment.