From 1586baf96469f5651b7d0886feb197121ba966bd Mon Sep 17 00:00:00 2001 From: Sam Mort <29308020+sammort@users.noreply.github.com> Date: Thu, 4 Jun 2026 00:38:28 +0100 Subject: [PATCH] fix: #2116 fix SSL errors and session cookies for Vale of White Horse This change fixes the current SSL errors received when connecting to Vale of White Horse's BINZONE web application. Also pulling in the fixes for session cookies applied to South Oxfordshire in bf6dd1fc476b5602f92bb281994683b77aa3a469 as both councils use the same application. --- .../councils/ValeofWhiteHorseCouncil.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/uk_bin_collection/uk_bin_collection/councils/ValeofWhiteHorseCouncil.py b/uk_bin_collection/uk_bin_collection/councils/ValeofWhiteHorseCouncil.py index 558e53eb92..b9f1db5e11 100644 --- a/uk_bin_collection/uk_bin_collection/councils/ValeofWhiteHorseCouncil.py +++ b/uk_bin_collection/uk_bin_collection/councils/ValeofWhiteHorseCouncil.py @@ -18,9 +18,6 @@ def parse_data(self, page: str, **kwargs) -> dict: check_uprn(user_uprn) # UPRN is passed in via a cookie. Set cookies/params and GET the page - cookies = { - "SVBINZONE": f"VALE%3AUPRN%40{user_uprn}", - } headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "en-GB,en;q=0.7", @@ -40,11 +37,23 @@ def parse_data(self, page: str, **kwargs) -> dict: "ebd": "0", } requests.packages.urllib3.disable_warnings() - response = requests.get( + # Azure App Gateway intermittently returns 403 on direct requests. + # Establishing a JSESSIONID by visiting the page first (without the + # SVBINZONE cookie) avoids this. + session = requests.Session() + session.headers.update(headers) + session.get( + "https://eform.whitehorsedc.gov.uk/ebase/BINZONE_DESKTOP.eb?SOVA_TAG=VALE&ebd=0&ebz=1_1780529431339", + verify=False, + timeout=15, + ) + session.cookies.set("SVBINZONE", f"VALE%3AUPRN%40{user_uprn}") + response = session.get( "https://eform.whitehorsedc.gov.uk/ebase/BINZONE_DESKTOP.eb", params=params, headers=headers, - cookies=cookies, + verify=False, + timeout=15, ) # Parse response text for super speedy finding