Skip to content

Commit

Permalink
fix: Midlothian Council
Browse files Browse the repository at this point in the history
fix: robbrad#1192 - Adding Next Page support
  • Loading branch information
m26dvd committed Jan 28, 2025
1 parent 2b9059a commit 7c68842
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions uk_bin_collection/uk_bin_collection/councils/MidlothianCouncil.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ def _get_result_by_identifier(self, soup, identifier: str) -> list:
if pattern.match(link_text):
return address_link

try:
print("Finding next page link not found.")
# Find the 'Next page' link
next_page_link = soup.find("a", class_="button float-right")

# Ensure the link exists
if next_page_link:
# Extract the href attribute
next_page_url = next_page_link["href"]

# Send a GET request to the next page
next_response = requests.get(next_page_url)
next_response.raise_for_status() # Raise an exception for HTTP errors

# Parse the HTML content of the next page
soup = BeautifulSoup(next_response.text, "html.parser")
address_link = self._get_result_by_identifier(soup, identifier)
return address_link
else:
print("Next page link not found.")
except AttributeError as e:
print(f"Warning: Could not find the search results. Error: {e}")
return None # Return None if no result found

print(f"Warning: No results found for identifier '{identifier}'.")
return None # Return None if no match is found

Expand Down

0 comments on commit 7c68842

Please sign in to comment.