Repository: mampfes/hacs_waste_collection_schedule

Issue:
`fccenvironment_co_uk.py` no longer works
Tests are failing for some of the `fccenvironment.co.uk` related collection schedules as raised by @mothy-tim [here](https://github.com/mampfes/hacs_waste_collection_schedule/issues/268#issuecomment-1447053595) - further investigation shows that these domains have incorrectly installed certificates.

* https://www.sslshopper.com/ssl-checker.html#hostname=www.fccenvironment.co.uk
![Screenshot 2023-02-27 at 22 16 33](https://user-images.githubusercontent.com/6557665/221698385-7c526b46-1587-4be1-9d17-9427e3367add.png)
* https://www.sslshopper.com/ssl-checker.html#hostname=westdevon.fccenvironment.co.uk
![Screenshot 2023-02-27 at 22 17 16](https://user-images.githubusercontent.com/6557665/221698514-d5a44378-14c0-4389-b3aa-d3c669673219.png)

I'm happy to reach out to fccenvironment.co.uk to let them know they've improperly installed these certificates, however, I doubt we'll get back any kind of worthwhile response.

I'll be opening a Pull Request to skip TLS Verification for these domains, not an ideal solution, but a decent enough workaround. Should fccenvironment.co.uk respond to my email and fix their cert chain I'll open another PR to revert these commits.


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/fccenvironment_co_uk.py
@@ -1,10 +1,13 @@
 from urllib.parse import urlparse
 
 import requests
+import urllib3
 from bs4 import BeautifulSoup
 from dateutil import parser
 from waste_collection_schedule import Collection
 
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+
 TITLE = "FCC Environment"
 DESCRIPTION = """
     Consolidated source for waste collection services for ~60 local authorities.
@@ -46,7 +49,7 @@ def __init__(self, uprn: str, region: str = "harborough") -> None:
     def getcollectiondetails(self, endpoint: str) -> list[Collection]:
         domain = urlparse(endpoint).netloc
         session = requests.Session()
-        cookies = session.get(f"https://{domain}/")
+        cookies = session.get(f"https://{domain}/", verify=False)
         response = session.post(
             endpoint,
             headers={
@@ -56,14 +59,13 @@ def getcollectiondetails(self, endpoint: str) -> list[Collection]:
                 "fcc_session_token": cookies.cookies["fcc_session_cookie"],
                 "uprn": self.uprn,
             },
+            verify=False,
         )
         results = {}
         for item in response.json()["binCollections"]["tile"]:
             try:
                 soup = BeautifulSoup(item[0], "html.parser")
-                date = parser.parse(
-                    soup.find_all("b")[2].text.split(",")[1].strip()
-                ).date()
+                date = parser.parse(soup.find_all("b")[2].text.split(",")[1].strip()).date()
                 service = soup.text.split("\n")[0]
             except parser._parser.ParserError:
                 continue
@@ -99,6 +101,7 @@ def harborough(self) -> list[Collection]:
         r = requests.post(
             "https://www.fccenvironment.co.uk/harborough/detail-address",
             data={"Uprn": self.uprn},
+            verify=False,
         )
         soup = BeautifulSoup(r.text, "html.parser")
         services = soup.find(
@@ -110,11 +113,7 @@ def harborough(self) -> list[Collection]:
             for type in _icons:
                 if type.lower() in service.text.lower():
                     try:
-                        date = parser.parse(
-                            service.find(
-                                "span", attrs={"class": "pull-right"}
-                            ).text.strip()
-                        ).date()
+                        date = parser.parse(service.find("span", attrs={"class": "pull-right"}).text.strip()).date()
                     except parser._parser.ParserError:
                         continue
 


Test patch: