Merge pull request #852 from dt215git/stevenage_SSL_fix

Stevenage fix
This commit is contained in:
Steffen Zimmermann
2023-04-07 15:17:21 +02:00
committed by GitHub

View File

@@ -1,9 +1,14 @@
import json
from datetime import datetime
import requests
# Suppress error messages relating to SSLCertVerificationError
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Stevenage Borough Council"
DESCRIPTION = "Source for stevenage.gov.uk services for Stevenage, UK."
URL = "https://stevenage.gov.uk"
@@ -30,7 +35,8 @@ class Source:
self._postcode = postcode
def fetch(self):
entries = []
s = requests.Session()
# Get Round ID and Round Code
# Don't fully understand significance of all of the fields, but API borks if they are not present
@@ -43,8 +49,8 @@ class Source:
}
headers = {"Content-type": "application/json", "Accept": "text/plain"}
roundRequest = requests.post(
SEARCH_URLS["round_search"], data=json.dumps(roundData), headers=headers
roundRequest = s.post(
SEARCH_URLS["round_search"], data=json.dumps(roundData), headers=headers, verify=False
)
roundJson = json.loads(roundRequest.text)
@@ -69,10 +75,10 @@ class Source:
],
}
collectionRequest = requests.post(
collectionRequest = s.post(
SEARCH_URLS["collection_search"],
data=json.dumps(collectionData),
headers=headers,
headers=headers,verify=False
)
collectionJson = json.loads(collectionRequest.text)