uk_bin_collection 0.118.0__py3-none-any.whl → 0.119.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- uk_bin_collection/tests/input.json +34 -0
- uk_bin_collection/uk_bin_collection/councils/AberdeenCityCouncil.py +122 -0
- uk_bin_collection/uk_bin_collection/councils/BraintreeDistrictCouncil.py +70 -0
- uk_bin_collection/uk_bin_collection/councils/BurnleyBoroughCouncil.py +88 -0
- uk_bin_collection/uk_bin_collection/councils/EdinburghCityCouncil.py +98 -0
- uk_bin_collection/uk_bin_collection/councils/ExeterCityCouncil.py +52 -0
- {uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/RECORD +11 -6
- {uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/entry_points.txt +0 -0
@@ -6,6 +6,12 @@
|
|
6
6
|
"wiki_name": "Aberdeenshire Council",
|
7
7
|
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
|
8
8
|
},
|
9
|
+
"AberdeenCityCouncil": {
|
10
|
+
"url": "https://www.aberdeencity.gov.uk",
|
11
|
+
"uprn": "9051156186",
|
12
|
+
"wiki_name": "Aberdeen City Council",
|
13
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
|
14
|
+
},
|
9
15
|
"AdurAndWorthingCouncils": {
|
10
16
|
"url": "https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061878829",
|
11
17
|
"wiki_command_url_override": "https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=XXXXXXXX",
|
@@ -213,6 +219,14 @@
|
|
213
219
|
"wiki_name": "Bradford MDC",
|
214
220
|
"wiki_note": "To get the UPRN, you will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search). Postcode isn't parsed by this script, but you can pass it in double quotes."
|
215
221
|
},
|
222
|
+
"BraintreeDistrictCouncil": {
|
223
|
+
"postcode": "CO5 9BD",
|
224
|
+
"skip_get_url": true,
|
225
|
+
"uprn": "10006930172",
|
226
|
+
"url": "https://www.braintree.gov.uk/",
|
227
|
+
"wiki_name": "Braintree District Council",
|
228
|
+
"wiki_note": "Provide your UPRN and postcode. Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
|
229
|
+
},
|
216
230
|
"BrecklandCouncil": {
|
217
231
|
"url": "https://www.breckland.gov.uk",
|
218
232
|
"wiki_command_url_override": "https://www.breckland.gov.uk",
|
@@ -276,6 +290,12 @@
|
|
276
290
|
"wiki_name": "Buckinghamshire Council (Chiltern, South Bucks, Wycombe)",
|
277
291
|
"wiki_note": "Pass the house name/number and postcode in their respective arguments, both wrapped in quotes."
|
278
292
|
},
|
293
|
+
"BurnleyBoroughCouncil": {
|
294
|
+
"uprn": "100010347165",
|
295
|
+
"url": "https://www.burnley.gov.uk",
|
296
|
+
"wiki_name": "Burnley Borough Council",
|
297
|
+
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
298
|
+
},
|
279
299
|
"BuryCouncil": {
|
280
300
|
"house_number": "3",
|
281
301
|
"postcode": "M26 3XY",
|
@@ -597,6 +617,14 @@
|
|
597
617
|
"wiki_name": "Eastleigh Borough Council",
|
598
618
|
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
599
619
|
},
|
620
|
+
"EdinburghCityCouncil": {
|
621
|
+
"skip_get_url": true,
|
622
|
+
"house_number": "Tuesday",
|
623
|
+
"postcode": "Week 1",
|
624
|
+
"url": "https://www.edinburgh.gov.uk",
|
625
|
+
"wiki_name": "Edinburgh City Council",
|
626
|
+
"wiki_note": "Use the House Number field to pass the DAY of the week for your collections. Monday/Tuesday/Wednesday/Thursday/Friday. Use the 'postcode' field to pass the WEEK for your collection. [Week 1/Week 2]"
|
627
|
+
},
|
600
628
|
"ElmbridgeBoroughCouncil": {
|
601
629
|
"url": "https://www.elmbridge.gov.uk",
|
602
630
|
"wiki_command_url_override": "https://www.elmbridge.gov.uk",
|
@@ -632,6 +660,12 @@
|
|
632
660
|
"wiki_name": "Erewash Borough Council",
|
633
661
|
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
634
662
|
},
|
663
|
+
"ExeterCityCouncil": {
|
664
|
+
"uprn": "100040212270",
|
665
|
+
"url": "https://www.exeter.gov.uk",
|
666
|
+
"wiki_name": "Exeter City Council",
|
667
|
+
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
668
|
+
},
|
635
669
|
"FalkirkCouncil": {
|
636
670
|
"url": "https://www.falkirk.gov.uk",
|
637
671
|
"wiki_command_url_override": "https://www.falkirk.gov.uk",
|
@@ -0,0 +1,122 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
import requests
|
4
|
+
|
5
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
6
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
7
|
+
|
8
|
+
|
9
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
10
|
+
class CouncilClass(AbstractGetBinDataClass):
|
11
|
+
"""
|
12
|
+
Concrete classes have to implement all abstract operations of the
|
13
|
+
base class. They can also override some operations with a default
|
14
|
+
implementation.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
18
|
+
|
19
|
+
user_uprn = kwargs.get("uprn")
|
20
|
+
check_uprn(user_uprn)
|
21
|
+
bindata = {"bins": []}
|
22
|
+
|
23
|
+
SESSION_URL = "https://integration.aberdeencity.gov.uk/authapi/isauthenticated?uri=https%253A%252F%252Fintegration.aberdeencity.gov.uk%252Fservice%252Fbin_collection_calendar___view&hostname=integration.aberdeencity.gov.uk&withCredentials=true"
|
24
|
+
|
25
|
+
API_URL = "https://integration.aberdeencity.gov.uk/apibroker/runLookup"
|
26
|
+
|
27
|
+
headers = {
|
28
|
+
"Content-Type": "application/json",
|
29
|
+
"Accept": "application/json",
|
30
|
+
"User-Agent": "Mozilla/5.0",
|
31
|
+
"X-Requested-With": "XMLHttpRequest",
|
32
|
+
"Referer": "https://integration.aberdeencity.gov.uk/fillform/?iframe_id=fillform-frame-1&db_id=",
|
33
|
+
}
|
34
|
+
s = requests.session()
|
35
|
+
r = s.get(SESSION_URL)
|
36
|
+
r.raise_for_status()
|
37
|
+
session_data = r.json()
|
38
|
+
sid = session_data["auth-session"]
|
39
|
+
params = {
|
40
|
+
"id": "583c08ffc47fe",
|
41
|
+
"repeat_against": "",
|
42
|
+
"noRetry": "true",
|
43
|
+
"getOnlyTokens": "undefined",
|
44
|
+
"log_id": "",
|
45
|
+
"app_name": "AF-Renderer::Self",
|
46
|
+
# unix_timestamp
|
47
|
+
"_": str(int(time.time() * 1000)),
|
48
|
+
"sid": sid,
|
49
|
+
}
|
50
|
+
|
51
|
+
r = s.post(API_URL, headers=headers, params=params)
|
52
|
+
r.raise_for_status()
|
53
|
+
|
54
|
+
data = r.json()
|
55
|
+
rows_data = data["integration"]["transformed"]["rows_data"]["0"]
|
56
|
+
if not isinstance(rows_data, dict):
|
57
|
+
raise ValueError("Invalid data returned from API")
|
58
|
+
token = rows_data["token"]
|
59
|
+
|
60
|
+
data = {
|
61
|
+
"formValues": {
|
62
|
+
"Section 1": {
|
63
|
+
"nauprn": {
|
64
|
+
"value": user_uprn,
|
65
|
+
},
|
66
|
+
"token": {
|
67
|
+
"value": token,
|
68
|
+
},
|
69
|
+
"mindate": {
|
70
|
+
"value": datetime.now().strftime("%Y-%m-%d"),
|
71
|
+
},
|
72
|
+
"maxdate": {
|
73
|
+
"value": (datetime.now() + timedelta(days=30)).strftime(
|
74
|
+
"%Y-%m-%d"
|
75
|
+
),
|
76
|
+
},
|
77
|
+
},
|
78
|
+
},
|
79
|
+
}
|
80
|
+
|
81
|
+
params = {
|
82
|
+
"id": "5a3141caf4016",
|
83
|
+
"repeat_against": "",
|
84
|
+
"noRetry": "true",
|
85
|
+
"getOnlyTokens": "undefined",
|
86
|
+
"log_id": "",
|
87
|
+
"app_name": "AF-Renderer::Self",
|
88
|
+
# unix_timestamp
|
89
|
+
"_": str(int(time.time() * 1000)),
|
90
|
+
"sid": sid,
|
91
|
+
}
|
92
|
+
|
93
|
+
r = s.post(API_URL, json=data, headers=headers, params=params)
|
94
|
+
r.raise_for_status()
|
95
|
+
|
96
|
+
data = r.json()
|
97
|
+
rows_data = data["integration"]["transformed"]["rows_data"]["0"]
|
98
|
+
if not isinstance(rows_data, dict):
|
99
|
+
raise ValueError("Invalid data returned from API")
|
100
|
+
|
101
|
+
date_pattern = re.compile(r"^(.*?)(Date\d+)$")
|
102
|
+
count_pattern = re.compile(r"^Count(.*)$")
|
103
|
+
for key, value in rows_data.items():
|
104
|
+
date_match = date_pattern.match(key)
|
105
|
+
# Match count keys
|
106
|
+
count_match = count_pattern.match(key)
|
107
|
+
if count_match:
|
108
|
+
continue
|
109
|
+
|
110
|
+
# Match date keys
|
111
|
+
date_match = date_pattern.match(key)
|
112
|
+
if date_match:
|
113
|
+
bin_type = date_match.group(1)
|
114
|
+
dict_data = {
|
115
|
+
"type": bin_type,
|
116
|
+
"collectionDate": datetime.strptime(value, "%A %d %B %Y").strftime(
|
117
|
+
date_format
|
118
|
+
),
|
119
|
+
}
|
120
|
+
bindata["bins"].append(dict_data)
|
121
|
+
|
122
|
+
return bindata
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
import requests
|
4
|
+
from bs4 import BeautifulSoup
|
5
|
+
|
6
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
7
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
8
|
+
|
9
|
+
|
10
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
11
|
+
class CouncilClass(AbstractGetBinDataClass):
|
12
|
+
"""
|
13
|
+
Concrete classes have to implement all abstract operations of the
|
14
|
+
base class. They can also override some operations with a default
|
15
|
+
implementation.
|
16
|
+
"""
|
17
|
+
|
18
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
19
|
+
|
20
|
+
user_postcode = kwargs.get("postcode")
|
21
|
+
user_uprn = kwargs.get("uprn")
|
22
|
+
check_postcode(user_postcode)
|
23
|
+
check_uprn(user_uprn)
|
24
|
+
bindata = {"bins": []}
|
25
|
+
|
26
|
+
URI = "https://www.braintree.gov.uk/xfp/form/554"
|
27
|
+
|
28
|
+
response = requests.get(URI)
|
29
|
+
soup = BeautifulSoup(response.content, "html.parser")
|
30
|
+
token = (soup.find("input", {"name": "__token"})).get("value")
|
31
|
+
|
32
|
+
headers = {
|
33
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
34
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
|
35
|
+
"Referer": "https://www.braintree.gov.uk/xfp/form/554",
|
36
|
+
}
|
37
|
+
|
38
|
+
form_data = {
|
39
|
+
"__token": token,
|
40
|
+
"page": "5730",
|
41
|
+
"locale": "en_GB",
|
42
|
+
"qe15dda0155d237d1ea161004d1839e3369ed4831_0_0": user_postcode,
|
43
|
+
"qe15dda0155d237d1ea161004d1839e3369ed4831_1_0": user_uprn,
|
44
|
+
"next": "Next",
|
45
|
+
}
|
46
|
+
collection_lookup = requests.post(URI, data=form_data, headers=headers)
|
47
|
+
collection_lookup.raise_for_status()
|
48
|
+
for results in BeautifulSoup(collection_lookup.text, "html.parser").find_all(
|
49
|
+
"div", class_="date_display"
|
50
|
+
):
|
51
|
+
collection_info = results.text.strip().split("\n")
|
52
|
+
collection_type = collection_info[0].strip()
|
53
|
+
|
54
|
+
# Skip if no collection date is found
|
55
|
+
if len(collection_info) < 2:
|
56
|
+
continue
|
57
|
+
|
58
|
+
collection_date = collection_info[1].strip()
|
59
|
+
|
60
|
+
dict_data = {
|
61
|
+
"type": collection_type,
|
62
|
+
"collectionDate": collection_date,
|
63
|
+
}
|
64
|
+
bindata["bins"].append(dict_data)
|
65
|
+
|
66
|
+
bindata["bins"].sort(
|
67
|
+
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
|
68
|
+
)
|
69
|
+
|
70
|
+
return bindata
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
import requests
|
4
|
+
|
5
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
6
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
7
|
+
|
8
|
+
|
9
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
10
|
+
class CouncilClass(AbstractGetBinDataClass):
|
11
|
+
"""
|
12
|
+
Concrete classes have to implement all abstract operations of the
|
13
|
+
base class. They can also override some operations with a default
|
14
|
+
implementation.
|
15
|
+
"""
|
16
|
+
|
17
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
18
|
+
|
19
|
+
user_uprn = kwargs.get("uprn")
|
20
|
+
check_uprn(user_uprn)
|
21
|
+
bindata = {"bins": []}
|
22
|
+
|
23
|
+
SESSION_URL = "https://your.burnley.gov.uk/authapi/isauthenticated?uri=https%253A%252F%252Fyour.burnley.gov.uk%252Fen%252FAchieveForms%252F%253Fform_uri%253Dsandbox-publish%253A%252F%252FAF-Process-b41dcd03-9a98-41be-93ba-6c172ba9f80c%252FAF-Stage-edb97458-fc4d-4316-b6e0-85598ec7fce8%252Fdefinition.json%2526redirectlink%253D%25252Fen%2526cancelRedirectLink%253D%25252Fen%2526consentMessage%253Dyes&hostname=your.burnley.gov.uk&withCredentials=true"
|
24
|
+
|
25
|
+
API_URL = "https://your.burnley.gov.uk/apibroker/runLookup"
|
26
|
+
|
27
|
+
headers = {
|
28
|
+
"Content-Type": "application/json",
|
29
|
+
"Accept": "application/json",
|
30
|
+
"User-Agent": "Mozilla/5.0",
|
31
|
+
"X-Requested-With": "XMLHttpRequest",
|
32
|
+
"Referer": "https://your.burnley.gov.uk/fillform/?iframe_id=fillform-frame-1&db_id=",
|
33
|
+
}
|
34
|
+
s = requests.session()
|
35
|
+
r = s.get(SESSION_URL)
|
36
|
+
r.raise_for_status()
|
37
|
+
session_data = r.json()
|
38
|
+
sid = session_data["auth-session"]
|
39
|
+
|
40
|
+
data = {
|
41
|
+
"formValues": {
|
42
|
+
"Section 1": {
|
43
|
+
"case_uprn1": {
|
44
|
+
"value": user_uprn,
|
45
|
+
}
|
46
|
+
},
|
47
|
+
},
|
48
|
+
}
|
49
|
+
|
50
|
+
params = {
|
51
|
+
"id": "607fe757df87c",
|
52
|
+
"repeat_against": "",
|
53
|
+
"noRetry": "false",
|
54
|
+
"getOnlyTokens": "undefined",
|
55
|
+
"log_id": "",
|
56
|
+
"app_name": "AF-Renderer::Self",
|
57
|
+
# unix_timestamp
|
58
|
+
"_": str(int(time.time() * 1000)),
|
59
|
+
"sid": sid,
|
60
|
+
}
|
61
|
+
|
62
|
+
r = s.post(API_URL, json=data, headers=headers, params=params)
|
63
|
+
r.raise_for_status()
|
64
|
+
|
65
|
+
data = r.json()
|
66
|
+
rows_data = data["integration"]["transformed"]["rows_data"]
|
67
|
+
if not isinstance(rows_data, dict):
|
68
|
+
raise ValueError("Invalid data returned from API")
|
69
|
+
|
70
|
+
current_year = (datetime.now()).year
|
71
|
+
for key, value in rows_data.items():
|
72
|
+
bin_type = value["display"].split(" - ")[0]
|
73
|
+
collection_date = datetime.strptime(
|
74
|
+
value["display"].split(" - ")[1], "%A %d %B"
|
75
|
+
)
|
76
|
+
|
77
|
+
if collection_date.month == 1:
|
78
|
+
collection_date = collection_date.replace(year=current_year + 1)
|
79
|
+
else:
|
80
|
+
collection_date = collection_date.replace(year=current_year)
|
81
|
+
|
82
|
+
dict_data = {
|
83
|
+
"type": bin_type,
|
84
|
+
"collectionDate": collection_date.strftime(date_format),
|
85
|
+
}
|
86
|
+
bindata["bins"].append(dict_data)
|
87
|
+
|
88
|
+
return bindata
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import re
|
2
|
+
import time
|
3
|
+
|
4
|
+
import requests
|
5
|
+
from bs4 import BeautifulSoup
|
6
|
+
from selenium.webdriver.common.by import By
|
7
|
+
from selenium.webdriver.support import expected_conditions as EC
|
8
|
+
from selenium.webdriver.support.ui import Select
|
9
|
+
from selenium.webdriver.support.wait import WebDriverWait
|
10
|
+
|
11
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
12
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
13
|
+
|
14
|
+
|
15
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
16
|
+
class CouncilClass(AbstractGetBinDataClass):
|
17
|
+
"""
|
18
|
+
Concrete classes have to implement all abstract operations of the
|
19
|
+
base class. They can also override some operations with a default
|
20
|
+
implementation.
|
21
|
+
"""
|
22
|
+
|
23
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
24
|
+
|
25
|
+
collection_day = kwargs.get("paon")
|
26
|
+
collection_week = kwargs.get("postcode")
|
27
|
+
bindata = {"bins": []}
|
28
|
+
|
29
|
+
days_of_week = [
|
30
|
+
"Monday",
|
31
|
+
"Tuesday",
|
32
|
+
"Wednesday",
|
33
|
+
"Thursday",
|
34
|
+
"Friday",
|
35
|
+
"Saturday",
|
36
|
+
"Sunday",
|
37
|
+
]
|
38
|
+
|
39
|
+
collection_weeks = ["Week 1", "Week 2"]
|
40
|
+
collection_week = collection_weeks.index(collection_week)
|
41
|
+
|
42
|
+
offset_days = days_of_week.index(collection_day)
|
43
|
+
|
44
|
+
if collection_week == 0:
|
45
|
+
recyclingstartDate = datetime(2024, 11, 4)
|
46
|
+
glassstartDate = datetime(2024, 11, 4)
|
47
|
+
refusestartDate = datetime(2024, 11, 11)
|
48
|
+
elif collection_week == 1:
|
49
|
+
recyclingstartDate = datetime(2024, 11, 11)
|
50
|
+
glassstartDate = datetime(2024, 11, 11)
|
51
|
+
refusestartDate = datetime(2024, 11, 4)
|
52
|
+
|
53
|
+
refuse_dates = get_dates_every_x_days(refusestartDate, 14, 28)
|
54
|
+
glass_dates = get_dates_every_x_days(glassstartDate, 14, 28)
|
55
|
+
recycling_dates = get_dates_every_x_days(recyclingstartDate, 14, 28)
|
56
|
+
|
57
|
+
for refuseDate in refuse_dates:
|
58
|
+
|
59
|
+
collection_date = (
|
60
|
+
datetime.strptime(refuseDate, "%d/%m/%Y") + timedelta(days=offset_days)
|
61
|
+
).strftime("%d/%m/%Y")
|
62
|
+
|
63
|
+
dict_data = {
|
64
|
+
"type": "Grey Bin",
|
65
|
+
"collectionDate": collection_date,
|
66
|
+
}
|
67
|
+
bindata["bins"].append(dict_data)
|
68
|
+
|
69
|
+
for recyclingDate in recycling_dates:
|
70
|
+
|
71
|
+
collection_date = (
|
72
|
+
datetime.strptime(recyclingDate, "%d/%m/%Y")
|
73
|
+
+ timedelta(days=offset_days)
|
74
|
+
).strftime("%d/%m/%Y")
|
75
|
+
|
76
|
+
dict_data = {
|
77
|
+
"type": "Green Bin",
|
78
|
+
"collectionDate": collection_date,
|
79
|
+
}
|
80
|
+
bindata["bins"].append(dict_data)
|
81
|
+
|
82
|
+
for glassDate in glass_dates:
|
83
|
+
|
84
|
+
collection_date = (
|
85
|
+
datetime.strptime(glassDate, "%d/%m/%Y") + timedelta(days=offset_days)
|
86
|
+
).strftime("%d/%m/%Y")
|
87
|
+
|
88
|
+
dict_data = {
|
89
|
+
"type": "Glass Box",
|
90
|
+
"collectionDate": collection_date,
|
91
|
+
}
|
92
|
+
bindata["bins"].append(dict_data)
|
93
|
+
|
94
|
+
bindata["bins"].sort(
|
95
|
+
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
|
96
|
+
)
|
97
|
+
|
98
|
+
return bindata
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
import requests
|
4
|
+
from bs4 import BeautifulSoup
|
5
|
+
|
6
|
+
from uk_bin_collection.uk_bin_collection.common import *
|
7
|
+
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
8
|
+
|
9
|
+
|
10
|
+
# import the wonderful Beautiful Soup and the URL grabber
|
11
|
+
class CouncilClass(AbstractGetBinDataClass):
|
12
|
+
"""
|
13
|
+
Concrete classes have to implement all abstract operations of the
|
14
|
+
base class. They can also override some operations with a default
|
15
|
+
implementation.
|
16
|
+
"""
|
17
|
+
|
18
|
+
def parse_data(self, page: str, **kwargs) -> dict:
|
19
|
+
|
20
|
+
user_uprn = kwargs.get("uprn")
|
21
|
+
check_uprn(user_uprn)
|
22
|
+
bindata = {"bins": []}
|
23
|
+
|
24
|
+
URI = f"https://exeter.gov.uk/repositories/hidden-pages/address-finder/?qsource=UPRN&qtype=bins&term={user_uprn}"
|
25
|
+
|
26
|
+
response = requests.get(URI)
|
27
|
+
response.raise_for_status()
|
28
|
+
|
29
|
+
data = response.json()
|
30
|
+
|
31
|
+
soup = BeautifulSoup(data[0]["Results"], "html.parser")
|
32
|
+
soup.prettify()
|
33
|
+
|
34
|
+
# Extract bin schedule
|
35
|
+
for section in soup.find_all("h2"):
|
36
|
+
bin_type = section.text.strip()
|
37
|
+
collection_date = section.find_next("h3").text.strip()
|
38
|
+
|
39
|
+
dict_data = {
|
40
|
+
"type": bin_type,
|
41
|
+
"collectionDate": datetime.strptime(
|
42
|
+
remove_ordinal_indicator_from_date_string(collection_date),
|
43
|
+
"%A, %d %B %Y",
|
44
|
+
).strftime(date_format),
|
45
|
+
}
|
46
|
+
bindata["bins"].append(dict_data)
|
47
|
+
|
48
|
+
bindata["bins"].sort(
|
49
|
+
key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
|
50
|
+
)
|
51
|
+
|
52
|
+
return bindata
|
@@ -2,7 +2,7 @@ uk_bin_collection/README.rst,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
2
2
|
uk_bin_collection/tests/council_feature_input_parity.py,sha256=DO6Mk4ImYgM5ZCZ-cutwz5RoYYWZRLYx2tr6zIs_9Rc,3843
|
3
3
|
uk_bin_collection/tests/features/environment.py,sha256=VQZjJdJI_kZn08M0j5cUgvKT4k3iTw8icJge1DGOkoA,127
|
4
4
|
uk_bin_collection/tests/features/validate_council_outputs.feature,sha256=SJK-Vc737hrf03tssxxbeg_JIvAH-ddB8f6gU1LTbuQ,251
|
5
|
-
uk_bin_collection/tests/input.json,sha256=
|
5
|
+
uk_bin_collection/tests/input.json,sha256=VrW-CMky0dYd1A4rBB2mvF3p8fp_F0X9bVH8MvqLIso,105481
|
6
6
|
uk_bin_collection/tests/output.schema,sha256=ZwKQBwYyTDEM4G2hJwfLUVM-5v1vKRvRK9W9SS1sd18,1086
|
7
7
|
uk_bin_collection/tests/step_defs/step_helpers/file_handler.py,sha256=Ygzi4V0S1MIHqbdstUlIqtRIwnynvhu4UtpweJ6-5N8,1474
|
8
8
|
uk_bin_collection/tests/step_defs/test_validate_council.py,sha256=VZ0a81sioJULD7syAYHjvK_-nT_Rd36tUyzPetSA0gk,3475
|
@@ -12,6 +12,7 @@ uk_bin_collection/tests/test_conftest.py,sha256=qI_zgGjNOnwE9gmZUiuirL1SYz3TFw5y
|
|
12
12
|
uk_bin_collection/tests/test_get_data.py,sha256=sFJz_Fd6o-1r2gdmzY52JGwVi0Of_mDzvYSoc7a3RUw,7239
|
13
13
|
uk_bin_collection/uk_bin_collection/collect_data.py,sha256=dB7wWXsJX4fm5bIf84lexkvHIcO54CZ3JPxqmS-60YY,4654
|
14
14
|
uk_bin_collection/uk_bin_collection/common.py,sha256=fJG9ruqsCYOaYm-fzRb_l5kTeeB7i9k7qphWt3t7kks,10107
|
15
|
+
uk_bin_collection/uk_bin_collection/councils/AberdeenCityCouncil.py,sha256=Je8VwVLK9KnYl9vqf2gWJ7ZYDgUq3A7caDiIzk5Xof8,4194
|
15
16
|
uk_bin_collection/uk_bin_collection/councils/AberdeenshireCouncil.py,sha256=aO1CSdyqa8oAD0fB79y1Q9bikAWCP_JFa7CsyTa2j9s,1655
|
16
17
|
uk_bin_collection/uk_bin_collection/councils/AdurAndWorthingCouncils.py,sha256=ppbrmm-MzB1wOulK--CU_0j4P-djNf3ozMhHnmQFqLo,1511
|
17
18
|
uk_bin_collection/uk_bin_collection/councils/AntrimAndNewtonabbeyCouncil.py,sha256=Hp5pteaC5RjL5ZqPZ564S9WQ6ZTKLMO6Dl_fxip2TUc,1653
|
@@ -39,6 +40,7 @@ uk_bin_collection/uk_bin_collection/councils/BlackburnCouncil.py,sha256=jHbCK8sL
|
|
39
40
|
uk_bin_collection/uk_bin_collection/councils/BoltonCouncil.py,sha256=WI68r8jB0IHPUT4CgmZMtng899AAMFTxkyTdPg9yLF8,4117
|
40
41
|
uk_bin_collection/uk_bin_collection/councils/BracknellForestCouncil.py,sha256=Llo1rULaAZ8rChVYZqXFFLo7CN6vbT0ULUJD6ActouY,9015
|
41
42
|
uk_bin_collection/uk_bin_collection/councils/BradfordMDC.py,sha256=BEWS2c62cOsf26jqn1AkNUvVmc5AlUADYLaQuPn9RY4,5456
|
43
|
+
uk_bin_collection/uk_bin_collection/councils/BraintreeDistrictCouncil.py,sha256=2vYHilpI8mSwC2Ykdr1gxYAN3excDWqF6AwtGbkwbTw,2441
|
42
44
|
uk_bin_collection/uk_bin_collection/councils/BrecklandCouncil.py,sha256=PX6A_pDvaN109aSNWmEhm88GFKfkClIkmbwGURWvsks,1744
|
43
45
|
uk_bin_collection/uk_bin_collection/councils/BrightonandHoveCityCouncil.py,sha256=k6qt4cds-Ejd97Z-__pw2BYvGVbFdc9SUfF73PPrTNA,5823
|
44
46
|
uk_bin_collection/uk_bin_collection/councils/BristolCityCouncil.py,sha256=kJmmDJz_kQ45DHmG7ocrUpNJonEn0kuXYEDQyZaf9ks,5576
|
@@ -47,6 +49,7 @@ uk_bin_collection/uk_bin_collection/councils/BromsgroveDistrictCouncil.py,sha256
|
|
47
49
|
uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py,sha256=JC6Qqou1Rj4awn2VP3iuvwFpYayKDTt2_JNuNitjSoY,2393
|
48
50
|
uk_bin_collection/uk_bin_collection/councils/BroxtoweBoroughCouncil.py,sha256=-Facq-ToQkcWUePpKBwq90LZUFxgUSydNL2sYaLX4yw,4473
|
49
51
|
uk_bin_collection/uk_bin_collection/councils/BuckinghamshireCouncil.py,sha256=_ELVUM5VLp1nwDxRpvpsp6n8SzLJvp_UyMp-i_MXYuo,4383
|
52
|
+
uk_bin_collection/uk_bin_collection/councils/BurnleyBoroughCouncil.py,sha256=GJf1OPvUVj3vqsR3KjG0DFHZrSBu4ogIz_MJeVV8tNA,3192
|
50
53
|
uk_bin_collection/uk_bin_collection/councils/BuryCouncil.py,sha256=H7wAxO1nfxkewVoRRolumq8bBJG04siE3jieFH3RGpQ,2632
|
51
54
|
uk_bin_collection/uk_bin_collection/councils/CalderdaleCouncil.py,sha256=OJZcHYlvZDzmBpjjPPm3J8CRK9Twc49vRj7O9c5fyQ4,4971
|
52
55
|
uk_bin_collection/uk_bin_collection/councils/CannockChaseDistrictCouncil.py,sha256=ZamevXN8_Q8mRZOTESWtkb8jVyDXkTczcmhXMAVVSkM,2276
|
@@ -88,11 +91,13 @@ uk_bin_collection/uk_bin_collection/councils/EastRenfrewshireCouncil.py,sha256=5
|
|
88
91
|
uk_bin_collection/uk_bin_collection/councils/EastRidingCouncil.py,sha256=oL-NqriLVy_NChGASNh8qTqeakLn4iP_XzoMC6VlPGM,5216
|
89
92
|
uk_bin_collection/uk_bin_collection/councils/EastSuffolkCouncil.py,sha256=qQ0oOfGd0sWcczse_B22YoeL9uj3og8v3UJLt_Sx29c,4353
|
90
93
|
uk_bin_collection/uk_bin_collection/councils/EastleighBoroughCouncil.py,sha256=V4Vso4DvawFiezKlmXbTlJEK9Sjhz9nA8WeYjwtO2e4,2310
|
94
|
+
uk_bin_collection/uk_bin_collection/councils/EdinburghCityCouncil.py,sha256=YRjNgevnCxfaAIU8BV9dkqG17NiT6S-hp7l-1rdLVgQ,3150
|
91
95
|
uk_bin_collection/uk_bin_collection/councils/ElmbridgeBoroughCouncil.py,sha256=TgBOaReHWBbm0avV7HqRf0x7cxDe9cacTUcP9TFFprs,3005
|
92
96
|
uk_bin_collection/uk_bin_collection/councils/EnfieldCouncil.py,sha256=2yR5p-kdApOm1gHiynNECP0jQDvaYHOiT6MAQJAvunE,6144
|
93
97
|
uk_bin_collection/uk_bin_collection/councils/EnvironmentFirst.py,sha256=_9QJYDHpdnYK5R6znvZk1w0F9GnPnI8G4b6I_p26h4U,1695
|
94
98
|
uk_bin_collection/uk_bin_collection/councils/EppingForestDistrictCouncil.py,sha256=cKFllQ4zt6MGkwiz_HedZvw3iL1kRMLA6Ct2spUE5og,2085
|
95
99
|
uk_bin_collection/uk_bin_collection/councils/ErewashBoroughCouncil.py,sha256=QTQA6NjZtTL2baDeerIQW1SQpawwu6kGDMGdVvYQRRo,2501
|
100
|
+
uk_bin_collection/uk_bin_collection/councils/ExeterCityCouncil.py,sha256=FPNyBuQFYGFECZfCemgeHr27bXJFVvadinw43h-G8qs,1623
|
96
101
|
uk_bin_collection/uk_bin_collection/councils/FalkirkCouncil.py,sha256=C3OA9PEhBsCYPzwsSdqVi_SbF8uiB186i2XfHWKd3VI,1694
|
97
102
|
uk_bin_collection/uk_bin_collection/councils/FarehamBoroughCouncil.py,sha256=25QxeN5q3ad1Wwexs2d-B7ooH0ru6pOUx58413FOTY4,2352
|
98
103
|
uk_bin_collection/uk_bin_collection/councils/FenlandDistrictCouncil.py,sha256=sFrnKzIE2tIcz0YrC6A9HcevzgNdf6E6_HLGMWDKtGw,2513
|
@@ -265,8 +270,8 @@ uk_bin_collection/uk_bin_collection/councils/YorkCouncil.py,sha256=I2kBYMlsD4bId
|
|
265
270
|
uk_bin_collection/uk_bin_collection/councils/council_class_template/councilclasstemplate.py,sha256=EQWRhZ2pEejlvm0fPyOTsOHKvUZmPnxEYO_OWRGKTjs,1158
|
266
271
|
uk_bin_collection/uk_bin_collection/create_new_council.py,sha256=m-IhmWmeWQlFsTZC4OxuFvtw5ZtB8EAJHxJTH4O59lQ,1536
|
267
272
|
uk_bin_collection/uk_bin_collection/get_bin_data.py,sha256=YvmHfZqanwrJ8ToGch34x-L-7yPe31nB_x77_Mgl_vo,4545
|
268
|
-
uk_bin_collection-0.
|
269
|
-
uk_bin_collection-0.
|
270
|
-
uk_bin_collection-0.
|
271
|
-
uk_bin_collection-0.
|
272
|
-
uk_bin_collection-0.
|
273
|
+
uk_bin_collection-0.119.0.dist-info/LICENSE,sha256=vABBUOzcrgfaTKpzeo-si9YVEun6juDkndqA8RKdKGs,1071
|
274
|
+
uk_bin_collection-0.119.0.dist-info/METADATA,sha256=9KFQUNN2qI6XpAW3T1a-Xh5JovSSHKaXGPpX41DP4hs,17574
|
275
|
+
uk_bin_collection-0.119.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
276
|
+
uk_bin_collection-0.119.0.dist-info/entry_points.txt,sha256=36WCSGMWSc916S3Hi1ZkazzDKHaJ6CD-4fCEFm5MIao,90
|
277
|
+
uk_bin_collection-0.119.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{uk_bin_collection-0.118.0.dist-info → uk_bin_collection-0.119.0.dist-info}/entry_points.txt
RENAMED
File without changes
|