Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat eppingforestdistrictcouncil #740

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ Feature: Test each council output matches expected results
| council |
| EnvironmentFirst |

@EppingForestDistrictCouncil
Examples: EppingForestDistrictCouncil
| council |
| EppingForestDistrictCouncil |

@ErewashBoroughCouncil
Examples: ErewashBoroughCouncil
| council |
Expand Down
5 changes: 5 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@
"wiki_name": "Environment First",
"wiki_note": "For properties with collections managed by Environment First, such as Lewes and Eastbourne.\nReplace the XXXXXXXXXXX with the UPRN of your property - you can use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find this."
},
"EppingForestDistrictCouncil": {
"postcode": "IG9 6EP",
"url": "https://eppingforestdc.maps.arcgis.com/apps/instant/lookup/index.html?appid=bfca32b46e2a47cd9c0a84f2d8cdde17&find=IG9%206EP",
"wiki_name": "Epping Forest District Council"
},
"ErewashBoroughCouncil": {
"skip_get_url": true,
"uprn": "10003582028",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from bs4 import BeautifulSoup
from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from datetime import datetime
class CouncilClass(AbstractGetBinDataClass):
def parse_data(self, page: str, **kwargs) -> dict:
postcode = kwargs.get('postcode', '')
web_driver = kwargs.get("web_driver")
headless = kwargs.get("headless")

options = webdriver.ChromeOptions()
if headless:
options.add_argument('--headless')
driver = create_webdriver(web_driver, headless)

try:
driver.get(f"https://eppingforestdc.maps.arcgis.com/apps/instant/lookup/index.html?appid=bfca32b46e2a47cd9c0a84f2d8cdde17&find={postcode}")
wait = WebDriverWait(driver, 10)
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".esri-feature-content")))
html_content = driver.page_source

soup = BeautifulSoup(html_content, 'html.parser')
bin_info_divs = soup.select(".esri-feature-content p")
data = {"bins": []}
for div in bin_info_divs:
if 'collection day is' in div.text:
bin_type, date_str = div.text.split(' collection day is ')
bin_dates = datetime.strptime(date_str.strip(), '%d/%m/%Y').strftime('%Y-%m-%d')
data["bins"].append({"type": bin_type.strip(), "collectionDate": bin_dates})

return data
finally:
driver.quit()