mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
tidy-up
This commit is contained in:
@@ -15,7 +15,7 @@ URL = "https://wigan.gov.uk"
|
||||
|
||||
TEST_CASES = {
|
||||
"Test_001": {"postcode": "WN5 9BH", "uprn": "100011821616"},
|
||||
"Test_002": {"postcode": "WN6 8RG", "uprn": "100011776568"},
|
||||
"Test_002": {"postcode": "WN6 8RG", "uprn": "100011776859"},
|
||||
"Test_003": {"postcode": "wn36au", "uprn": 100011749007},
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@ ICON_MAP = {
|
||||
REGEX_ORDINALS = r"(st|nd|rd|th)"
|
||||
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, postcode, uprn):
|
||||
self._postcode = str(postcode.upper().strip())
|
||||
self._postcode = str(postcode.upper())
|
||||
self._uprn = str(uprn).zfill(12)
|
||||
|
||||
def get_asp_var(self, broth, id) -> str:
|
||||
@@ -40,16 +39,17 @@ class Source:
|
||||
return asp_var
|
||||
|
||||
def fetch(self):
|
||||
# Initial a session to generate required ASP variables
|
||||
|
||||
# Initiate a session to generate required ASP variables
|
||||
s= requests.Session()
|
||||
r0 = s.get("https://apps.wigan.gov.uk/MyNeighbourhood/")
|
||||
soup = BeautifulSoup(r0.text, "html.parser")
|
||||
|
||||
# Build initial search payload
|
||||
payload = {
|
||||
"__VIEWSTATE": get_asp_var(soup, "__VIEWSTATE"),
|
||||
"__VIEWSTATEGENERATOR": get_asp_var(soup, "__VIEWSTATEGENERATOR"),
|
||||
"__EVENTVALIDATION": get_asp_var(soup, "__EVENTVALIDATION"),
|
||||
"__VIEWSTATE": self.get_asp_var(soup, "__VIEWSTATE"),
|
||||
"__VIEWSTATEGENERATOR": self.get_asp_var(soup, "__VIEWSTATEGENERATOR"),
|
||||
"__EVENTVALIDATION": self.get_asp_var(soup, "__EVENTVALIDATION"),
|
||||
"ctl00$ContentPlaceHolder1$txtPostcode": self._postcode,
|
||||
"ctl00$ContentPlaceHolder1$btnPostcodeSearch": "Search",
|
||||
}
|
||||
@@ -63,9 +63,9 @@ class Source:
|
||||
"__EVENTTARGET": "ctl00$ContentPlaceHolder1$lstAddresses",
|
||||
"__EVENTARGUMENT": "",
|
||||
"__LASTFOCUS": "",
|
||||
"__VIEWSTATE": get_asp_var(soup, "__VIEWSTATE"),
|
||||
"__VIEWSTATEGENERATOR": get_asp_var(soup, "__VIEWSTATEGENERATOR"),
|
||||
"__EVENTVALIDATION": get_asp_var(soup, "__EVENTVALIDATION"),
|
||||
"__VIEWSTATE": self.get_asp_var(soup, "__VIEWSTATE"),
|
||||
"__VIEWSTATEGENERATOR": self.get_asp_var(soup, "__VIEWSTATEGENERATOR"),
|
||||
"__EVENTVALIDATION": self.get_asp_var(soup, "__EVENTVALIDATION"),
|
||||
"ctl00$ContentPlaceHolder1$txtPostcode": self._postcode,
|
||||
"ctl00$ContentPlaceHolder1$lstAddresses": "UPRN" + self._uprn,
|
||||
}
|
||||
@@ -76,7 +76,6 @@ class Source:
|
||||
|
||||
# Extract the collection schedules
|
||||
bin_collections = soup.findAll("div", {"class": "BinsRecycling"})
|
||||
|
||||
entries = []
|
||||
for bin in bin_collections:
|
||||
waste_type = bin.find("h2").text
|
||||
|
||||
Reference in New Issue
Block a user