@@ -21,8 +21,8 @@ def parse_data(self, page: str, **kwargs) -> dict:
21
21
check_postcode (user_postcode )
22
22
bindata = {"bins" : []}
23
23
24
- session_uri = "https://www.oxford.gov.uk/mybinday "
25
- URI = "https://www.oxford.gov.uk/xfp/form/142"
24
+ session_uri = "https://www.oxford.gov.uk/xfp/form/142 "
25
+ URI = "https://www.oxford.gov.uk/xfp/form/142#q6ad4e3bf432c83230a0347a6eea6c805c672efeb_0 "
26
26
27
27
session = requests .Session ()
28
28
token_response = session .get (session_uri )
@@ -40,15 +40,18 @@ def parse_data(self, page: str, **kwargs) -> dict:
40
40
41
41
collection_response = session .post (URI , data = form_data )
42
42
43
- collection_soup = BeautifulSoup (collection_response .text , "html.parser" )
44
- for paragraph in collection_soup .find ("div" , class_ = "editor" ).find_all ("p" ):
45
- matches = re .match (r"^(\w+) Next Collection: (.*)" , paragraph .text )
43
+ soup = BeautifulSoup (collection_response .text , "html.parser" )
44
+ #print(soup)
45
+
46
+ for paragraph in soup .find ("div" , class_ = "editor" ).find_all ("p" ):
47
+ matches = re .match (r"^Your next (\w+) collections: (.*)" , paragraph .text )
46
48
if matches :
47
49
collection_type , date_string = matches .groups ()
50
+ parts = date_string .split (', ' , 1 )
48
51
try :
49
- date = datetime .strptime (date_string , "%A %d %B %Y" ).date ()
52
+ date = datetime .strptime (parts [ 0 ] , "%A %d %B %Y" ).date ()
50
53
except ValueError :
51
- date = datetime .strptime (date_string , "%A %d %b %Y" ).date ()
54
+ date = datetime .strptime (parts [ 0 ] , "%A %d %b %Y" ).date ()
52
55
53
56
dict_data = {
54
57
"type" : collection_type ,
@@ -61,3 +64,5 @@ def parse_data(self, page: str, **kwargs) -> dict:
61
64
)
62
65
63
66
return bindata
67
+
68
+
0 commit comments