Skip to content

Commit

Permalink
fix: Remove invalid escape sequence warnings from West Lindsey Distri…
Browse files Browse the repository at this point in the history
…ct Council
  • Loading branch information
dp247 committed Dec 19, 2024
1 parent 048b75f commit 152c0b0
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parse_data(self, page: str, **kwargs) -> dict:

# Strip data and parse the JSON
address_data = json.loads(
re.sub("getAddressesCallback\d+\(", "", address_data)[:-2]
re.sub(r"getAddressesCallback\d+\(", "", address_data)[:-2]
)

if address_data["TotalHits"] == 0:
Expand All @@ -48,9 +48,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
address_x = address_data["Locations"][0]["X"]
address_y = address_data["Locations"][0]["Y"]

stage2_url = "https://wlnk.statmap.co.uk/map/Cluster.svc/getpage?script=\Cluster\Cluster.AuroraScript$&taskId=bins&format=js&updateOnly=true&query=x%3D{}%3By%3D{}%3Bid%3D{}".format(
address_x, address_y, address_id
)
stage2_url = fr"https://wlnk.statmap.co.uk/map/Cluster.svc/getpage?script=\Cluster\Cluster.AuroraScript$&taskId=bins&format=js&updateOnly=true&query=x%3D{address_x}%3By%3D{address_y}%3Bid%3D{address_id}"

bin_query = requests.get(stage2_url).text

Expand All @@ -61,7 +59,7 @@ def parse_data(self, page: str, **kwargs) -> dict:
)

# Return only the HTML contained within the Javascript function payload.
pattern = 'document\.getElementById\("DR1"\)\.innerHTML="(.+)";'
pattern = r'document\.getElementById\("DR1"\)\.innerHTML="(.+)";'

bin_html = re.findall(pattern, bin_query)

Expand All @@ -86,7 +84,7 @@ def parse_data(self, page: str, **kwargs) -> dict:

# Get bin date
bin_date_text = row.text
pattern = "\d+\/\d+"
pattern = r"\d+\/\d+"
bin_dates = re.findall(pattern, bin_date_text)

for bin_date in bin_dates:
Expand Down

0 comments on commit 152c0b0

Please sign in to comment.