uk_bin_collection 0.119.0__py3-none-any.whl → 0.121.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. uk_bin_collection/tests/input.json +116 -9
  2. uk_bin_collection/uk_bin_collection/councils/BaberghDistrictCouncil.py +3 -1
  3. uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py +102 -0
  4. uk_bin_collection/uk_bin_collection/councils/CotswoldDistrictCouncil.py +3 -3
  5. uk_bin_collection/uk_bin_collection/councils/CumberlandAllerdaleCouncil.py +93 -0
  6. uk_bin_collection/uk_bin_collection/councils/EastAyrshireCouncil.py +11 -8
  7. uk_bin_collection/uk_bin_collection/councils/EnvironmentFirst.py +14 -0
  8. uk_bin_collection/uk_bin_collection/councils/FolkstoneandHytheDistrictCouncil.py +81 -0
  9. uk_bin_collection/uk_bin_collection/councils/HackneyCouncil.py +85 -0
  10. uk_bin_collection/uk_bin_collection/councils/HartlepoolBoroughCouncil.py +83 -0
  11. uk_bin_collection/uk_bin_collection/councils/KingsLynnandWestNorfolkBC.py +59 -0
  12. uk_bin_collection/uk_bin_collection/councils/LondonBoroughHavering.py +75 -0
  13. uk_bin_collection/uk_bin_collection/councils/LondonBoroughLewisham.py +132 -0
  14. uk_bin_collection/uk_bin_collection/councils/MidSuffolkDistrictCouncil.py +3 -1
  15. uk_bin_collection/uk_bin_collection/councils/MorayCouncil.py +65 -0
  16. uk_bin_collection/uk_bin_collection/councils/NewcastleUnderLymeCouncil.py +66 -0
  17. uk_bin_collection/uk_bin_collection/councils/NorthHertfordshireDistrictCouncil.py +93 -0
  18. uk_bin_collection/uk_bin_collection/councils/RoyalBoroughofGreenwich.py +113 -0
  19. uk_bin_collection/uk_bin_collection/councils/SandwellBoroughCouncil.py +87 -0
  20. uk_bin_collection/uk_bin_collection/councils/ThurrockCouncil.py +93 -0
  21. uk_bin_collection/uk_bin_collection/councils/WestNorthamptonshireCouncil.py +12 -10
  22. uk_bin_collection/uk_bin_collection/councils/WyreForestDistrictCouncil.py +65 -0
  23. {uk_bin_collection-0.119.0.dist-info → uk_bin_collection-0.121.0.dist-info}/METADATA +1 -1
  24. {uk_bin_collection-0.119.0.dist-info → uk_bin_collection-0.121.0.dist-info}/RECORD +27 -12
  25. {uk_bin_collection-0.119.0.dist-info → uk_bin_collection-0.121.0.dist-info}/LICENSE +0 -0
  26. {uk_bin_collection-0.119.0.dist-info → uk_bin_collection-0.121.0.dist-info}/WHEEL +0 -0
  27. {uk_bin_collection-0.119.0.dist-info → uk_bin_collection-0.121.0.dist-info}/entry_points.txt +0 -0
@@ -88,9 +88,10 @@
88
88
  "skip_get_url": true,
89
89
  "house_number": "Monday",
90
90
  "postcode": "Week 1",
91
+ "uprn": "Tuesday",
91
92
  "url": "https://www.babergh.gov.uk",
92
93
  "wiki_name": "Babergh District Council",
93
- "wiki_note": "Use the House Number field to pass the DAY of the week for your collections. Monday/Tuesday/Wednesday/Thursday/Friday. [OPTIONAL] Use the 'postcode' field to pass the WEEK for your garden collection. [Week 1/Week 2]"
94
+ "wiki_note": "Use the House Number field to pass the DAY of the week for your NORMAL collections. [Monday/Tuesday/Wednesday/Thursday/Friday]. [OPTIONAL] Use the 'postcode' field to pass the WEEK for your garden collection. [Week 1/Week 2]. [OPTIONAL] Use the 'uprn' field to pass the DAY for your garden collection. [Monday/Tuesday/Wednesday/Thursday/Friday]"
94
95
  },
95
96
  "BCPCouncil": {
96
97
  "skip_get_url": true,
@@ -363,6 +364,14 @@
363
364
  "wiki_name": "Chelmsford City Council",
364
365
  "wiki_note": "Follow the instructions [here](https://www.chelmsford.gov.uk/myhome/) until you get the page listing your address, then copy the entire address text and use that in the house number field."
365
366
  },
367
+ "CheltenhamBoroughCouncil": {
368
+ "skip_get_url": true,
369
+ "house_number": "Monday",
370
+ "postcode": "Week 1",
371
+ "url": "https://www.cheltenham.gov.uk",
372
+ "wiki_name": "Cheltenham Borough Council",
373
+ "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 (wrapped in quotes) for your collections. [Week 1/Week 2]."
374
+ },
366
375
  "CheshireEastCouncil": {
367
376
  "url": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=100012791226&onelineaddress=3%20COBBLERS%20YARD,%20SK9%207DZ&_=1689413260149",
368
377
  "wiki_command_url_override": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=XXXXXXXX&onelineaddress=XXXXXXXX&_=1689413260149",
@@ -468,6 +477,13 @@
468
477
  "wiki_name": "Croydon Council",
469
478
  "wiki_note": "Pass the house number and postcode in their respective parameters."
470
479
  },
480
+ "CumberlandAllerdaleCouncil": {
481
+ "house_number": "2",
482
+ "postcode": "CA13 0DE",
483
+ "url": "https://www.allerdale.gov.uk",
484
+ "wiki_name": "Cumberland Council - Allerdale District",
485
+ "wiki_note": "Pass the house number and postcode in their respective parameters."
486
+ },
471
487
  "DacorumBoroughCouncil": {
472
488
  "house_number": "13",
473
489
  "postcode": "HP3 9JY",
@@ -715,6 +731,13 @@
715
731
  "wiki_name": "Flintshire County Council",
716
732
  "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
717
733
  },
734
+ "FolkstoneandHytheDistrictCouncil": {
735
+ "skip_get_url": true,
736
+ "uprn": "50032097",
737
+ "url": "https://www.folkestone-hythe.gov.uk",
738
+ "wiki_name": "Folkstone and Hythe District Council",
739
+ "wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
740
+ },
718
741
  "ForestOfDeanDistrictCouncil": {
719
742
  "house_number": "ELMOGAL, PARKEND ROAD, BREAM, LYDNEY",
720
743
  "postcode": "GL15 6JT",
@@ -773,6 +796,13 @@
773
796
  "wiki_name": "Guildford Council",
774
797
  "wiki_note": "If the bin day is 'today' then the collectionDate will only show today's date if before 7 AM; else the date will be in 'previousCollectionDate'. To get the UPRN, you will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
775
798
  },
799
+ "HackneyCouncil": {
800
+ "house_number": "101",
801
+ "postcode": "N16 9AS",
802
+ "url": "https://www.hackney.gov.uk",
803
+ "wiki_name": "Hackney Council",
804
+ "wiki_note": "Pass the postcode and house number in their respective arguments, both wrapped in quotes."
805
+ },
776
806
  "HaltonBoroughCouncil": {
777
807
  "house_number": "12",
778
808
  "postcode": "WA7 4HA",
@@ -810,6 +840,12 @@
810
840
  "wiki_name": "Harrogate Borough Council",
811
841
  "wiki_note": "Pass the UPRN, which can be found at [this site](https://secure.harrogate.gov.uk/inmyarea). URL doesn't need to be passed."
812
842
  },
843
+ "HartlepoolBoroughCouncil": {
844
+ "url": "https://www.hartlepool.gov.uk",
845
+ "uprn": "100110019551",
846
+ "wiki_name": "Hartlepool Borough Council",
847
+ "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
848
+ },
813
849
  "HertsmereBoroughCouncil": {
814
850
  "house_number": "1",
815
851
  "postcode": "WD7 9HZ",
@@ -865,6 +901,12 @@
865
901
  "wiki_name": "Islington Council",
866
902
  "wiki_note": "Replace XXXXXXXX with your UPRN."
867
903
  },
904
+ "KingsLynnandWestNorfolkBC": {
905
+ "uprn": "10023636886",
906
+ "url": "https://www.west-norfolk.gov.uk/",
907
+ "wiki_name": "Kings Lynn and West Norfolk Borough Council",
908
+ "wiki_note": "Provide your UPRN. Find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
909
+ },
868
910
  "KingstonUponThamesCouncil": {
869
911
  "url": "https://waste-services.kingston.gov.uk/waste/2701097",
870
912
  "wiki_command_url_override": "https://waste-services.kingston.gov.uk/waste/XXXXXXX",
@@ -950,6 +992,12 @@
950
992
  "wiki_name": "London Borough Harrow",
951
993
  "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
952
994
  },
995
+ "LondonBoroughHavering": {
996
+ "url": "https://www.havering.gov.uk",
997
+ "uprn": "100021380730",
998
+ "wiki_name": "London Borough Havering",
999
+ "wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1000
+ },
953
1001
  "LondonBoroughHounslow": {
954
1002
  "skip_get_url": true,
955
1003
  "uprn": "100021577765",
@@ -964,6 +1012,15 @@
964
1012
  "wiki_name": "London Borough Lambeth",
965
1013
  "wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
966
1014
  },
1015
+ "LondonBoroughLewisham": {
1016
+ "postcode": "SE12 9QF",
1017
+ "skip_get_url": true,
1018
+ "uprn": "100021954849",
1019
+ "url": "https://www.lewisham.gov.uk",
1020
+ "web_driver": "http://selenium:4444",
1021
+ "wiki_name": "London Borough Lewisham",
1022
+ "wiki_note": "Pass the UPRN and postcode. To get the UPRN, you can use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1023
+ },
967
1024
  "LondonBoroughRedbridge": {
968
1025
  "postcode": "IG2 6LQ",
969
1026
  "uprn": "10023770353",
@@ -1047,9 +1104,10 @@
1047
1104
  "skip_get_url": true,
1048
1105
  "house_number": "Monday",
1049
1106
  "postcode": "Week 2",
1107
+ "uprn": "Monday",
1050
1108
  "url": "https://www.midsuffolk.gov.uk",
1051
1109
  "wiki_name": "Mid Suffolk District Council",
1052
- "wiki_note": "Use the House Number field to pass the DAY of the week for your collections. Monday/Tuesday/Wednesday/Thursday/Friday. [OPTIONAL] Use the 'postcode' field to pass the WEEK for your garden collection. [Week 1/Week 2]"
1110
+ "wiki_note": "Use the House Number field to pass the DAY of the week for your NORMAL collections. [Monday/Tuesday/Wednesday/Thursday/Friday]. [OPTIONAL] Use the 'postcode' field to pass the WEEK for your garden collection. [Week 1/Week 2]. [OPTIONAL] Use the 'uprn' field to pass the DAY for your garden collection. [Monday/Tuesday/Wednesday/Thursday/Friday]"
1053
1111
  },
1054
1112
  "MidSussexDistrictCouncil": {
1055
1113
  "house_number": "OAKLANDS, OAKLANDS ROAD RH16 1SS",
@@ -1074,6 +1132,12 @@
1074
1132
  "wiki_name": "Mole Valley District Council",
1075
1133
  "wiki_note": "UPRN can only be parsed with a valid postcode."
1076
1134
  },
1135
+ "MorayCouncil": {
1136
+ "uprn": "28841",
1137
+ "url": "https://bindayfinder.moray.gov.uk/",
1138
+ "wiki_name": "Moray Council",
1139
+ "wiki_note": "Find your property ID by going to (https://bindayfinder.moray.gov.uk), search for your property and extracting the ID from the URL. i.e. (https://bindayfinder.moray.gov.uk/disp_bins.php?id=00028841)"
1140
+ },
1077
1141
  "NeathPortTalbotCouncil": {
1078
1142
  "house_number": "2",
1079
1143
  "postcode": "SA13 3BA",
@@ -1104,6 +1168,12 @@
1104
1168
  "wiki_name": "Newcastle City Council",
1105
1169
  "wiki_note": "Replace XXXXXXXX with your UPRN."
1106
1170
  },
1171
+ "NewcastleUnderLymeCouncil": {
1172
+ "url": "https://www.newcastle-staffs.gov.uk",
1173
+ "uprn": "100031725433",
1174
+ "wiki_name": "Newcastle Under Lyme Council",
1175
+ "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
1176
+ },
1107
1177
  "NewhamCouncil": {
1108
1178
  "skip_get_url": true,
1109
1179
  "url": "https://bincollection.newham.gov.uk/Details/Index/000046029461",
@@ -1142,6 +1212,13 @@
1142
1212
  "wiki_name": "North East Lincolnshire Council",
1143
1213
  "wiki_note": "Replace XXXXXXXX with your UPRN."
1144
1214
  },
1215
+ "NorthHertfordshireDistrictCouncil": {
1216
+ "house_number": "2",
1217
+ "postcode": "SG6 4BJ",
1218
+ "url": "https://www.north-herts.gov.uk",
1219
+ "wiki_name": "North Hertfordshire District Council",
1220
+ "wiki_note": "Pass the house number and postcode in their respective parameters."
1221
+ },
1145
1222
  "NorthKestevenDistrictCouncil": {
1146
1223
  "url": "https://www.n-kesteven.org.uk/bins/display?uprn=100030869513",
1147
1224
  "wiki_command_url_override": "https://www.n-kesteven.org.uk/bins/display?uprn=XXXXXXXX",
@@ -1358,6 +1435,14 @@
1358
1435
  "wiki_command_url_override": "https://www.rotherham.gov.uk/bin-collections?address=XXXXXXXXX&submit=Submit",
1359
1436
  "wiki_note": "Replace `XXXXXXXXX` with your UPRN in the URL. You can find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1360
1437
  },
1438
+ "RoyalBoroughofGreenwich": {
1439
+ "house_number": "57",
1440
+ "postcode": "BR7 6DN",
1441
+ "skip_get_url": true,
1442
+ "url": "https://www.royalgreenwich.gov.uk",
1443
+ "wiki_name": "Royal Borough of Greenwich",
1444
+ "wiki_note": "Provide your house number in the `house_number` parameter and your postcode in the `postcode` parameter."
1445
+ },
1361
1446
  "RugbyBoroughCouncil": {
1362
1447
  "postcode": "CV22 6LA",
1363
1448
  "skip_get_url": true,
@@ -1388,6 +1473,13 @@
1388
1473
  "wiki_name": "Salford City Council",
1389
1474
  "wiki_note": "Provide your UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1390
1475
  },
1476
+ "SandwellBoroughCouncil": {
1477
+ "uprn": "10008755549",
1478
+ "skip_get_url": true,
1479
+ "url": "https://www.sandwell.gov.uk",
1480
+ "wiki_name": "Sandwell Borough Council",
1481
+ "wiki_note": "Pass the UPRN. You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1482
+ },
1391
1483
  "SeftonCouncil": {
1392
1484
  "house_number": "1",
1393
1485
  "postcode": "L20 6GG",
@@ -1503,10 +1595,10 @@
1503
1595
  "wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
1504
1596
  },
1505
1597
  "SouthStaffordshireDistrictCouncil": {
1506
- "uprn": "200004523954",
1507
- "url": "https://www.sstaffs.gov.uk/where-i-live?uprn=200004523954",
1508
- "wiki_name": "South Staffordshire District Council",
1509
- "wiki_note": "The URL needs to be `https://www.sstaffs.gov.uk/where-i-live?uprn=<Your_UPRN>`. Replace `<Your_UPRN>` with your UPRN."
1598
+ "uprn": "200004523954",
1599
+ "url": "https://www.sstaffs.gov.uk/where-i-live?uprn=200004523954",
1600
+ "wiki_name": "South Staffordshire District Council",
1601
+ "wiki_note": "The URL needs to be `https://www.sstaffs.gov.uk/where-i-live?uprn=<Your_UPRN>`. Replace `<Your_UPRN>` with your UPRN."
1510
1602
  },
1511
1603
  "SouthTynesideCouncil": {
1512
1604
  "house_number": "1",
@@ -1705,6 +1797,14 @@
1705
1797
  "wiki_name": "Three Rivers District Council",
1706
1798
  "wiki_note": "Provide your UPRN and postcode. Find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1707
1799
  },
1800
+ "ThurrockCouncil": {
1801
+ "skip_get_url": true,
1802
+ "house_number": "Monday",
1803
+ "postcode": "Round A",
1804
+ "url": "https://www.thurrock.gov.uk",
1805
+ "wiki_name": "Thurrock Council",
1806
+ "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 ROUND (wrapped in quotes) for your collections. [Round A/Round B]."
1807
+ },
1708
1808
  "TonbridgeAndMallingBC": {
1709
1809
  "postcode": "ME19 4JS",
1710
1810
  "skip_get_url": true,
@@ -1875,11 +1975,11 @@
1875
1975
  "wiki_note": "Provide your UPRN. You can find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1876
1976
  },
1877
1977
  "WestNorthamptonshireCouncil": {
1878
- "postcode": "NN3 2JB",
1978
+ "uprn": "28056796",
1879
1979
  "skip_get_url": true,
1880
- "url": "https://www.northampton.gov.uk/info/200084/bins-waste-and-recycling/1602/check-your-collection-day",
1980
+ "url": "https://www.westnorthants.gov.uk",
1881
1981
  "wiki_name": "West Northamptonshire Council",
1882
- "wiki_note": "Provide your postcode in the `postcode` parameter."
1982
+ "wiki_note": "Provide your UPRN. You can find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
1883
1983
  },
1884
1984
  "WestOxfordshireDistrictCouncil": {
1885
1985
  "house_number": "24",
@@ -1994,6 +2094,13 @@
1994
2094
  "wiki_name": "Wyre Council",
1995
2095
  "wiki_note": "Provide your UPRN and postcode. Find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search). The postcode should be wrapped in double quotes with a space in the middle."
1996
2096
  },
2097
+ "WyreForestDistrictCouncil": {
2098
+ "skip_get_url": true,
2099
+ "house_number": "Monday",
2100
+ "url": "https://www.wyreforestdc.gov.uk",
2101
+ "wiki_name": "Wyre Forest District Council",
2102
+ "wiki_note": "Use the House Number field to pass the DAY of the week for your collections. [Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday]."
2103
+ },
1997
2104
  "YorkCouncil": {
1998
2105
  "skip_get_url": true,
1999
2106
  "uprn": "100050535540",
@@ -24,6 +24,7 @@ class CouncilClass(AbstractGetBinDataClass):
24
24
 
25
25
  collection_day = kwargs.get("paon")
26
26
  garden_collection_week = kwargs.get("postcode")
27
+ garden_collection_day = kwargs.get("uprn")
27
28
  bindata = {"bins": []}
28
29
 
29
30
  days_of_week = [
@@ -42,6 +43,7 @@ class CouncilClass(AbstractGetBinDataClass):
42
43
  recyclingstartDate = datetime(2024, 11, 11)
43
44
 
44
45
  offset_days = days_of_week.index(collection_day)
46
+ offset_days_garden = days_of_week.index(garden_collection_day)
45
47
  if garden_collection_week:
46
48
  garden_collection = garden_week.index(garden_collection_week)
47
49
 
@@ -155,7 +157,7 @@ class CouncilClass(AbstractGetBinDataClass):
155
157
 
156
158
  collection_date = (
157
159
  datetime.strptime(gardenDate, "%d/%m/%Y")
158
- + timedelta(days=offset_days)
160
+ + timedelta(days=offset_days_garden)
159
161
  ).strftime("%d/%m/%Y")
160
162
 
161
163
  garden_holiday = next(
@@ -0,0 +1,102 @@
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
+ week = ["Week 1", "Week 2"]
40
+
41
+ offset_days = days_of_week.index(collection_day)
42
+ collection_week = week.index(collection_week)
43
+
44
+ if collection_week == 0:
45
+ refusestartDate = datetime(2024, 11, 25)
46
+ recyclingstartDate = datetime(2024, 11, 18)
47
+ else:
48
+ refusestartDate = datetime(2024, 11, 18)
49
+ recyclingstartDate = datetime(2024, 11, 25)
50
+
51
+ refuse_dates = get_dates_every_x_days(refusestartDate, 14, 28)
52
+ recycling_dates = get_dates_every_x_days(recyclingstartDate, 14, 28)
53
+ food_dates = get_dates_every_x_days(recyclingstartDate, 7, 56)
54
+
55
+ for refuseDate in refuse_dates:
56
+
57
+ collection_date = (
58
+ datetime.strptime(refuseDate, "%d/%m/%Y") + timedelta(days=offset_days)
59
+ ).strftime("%d/%m/%Y")
60
+
61
+ dict_data = {
62
+ "type": "Refuse Bin",
63
+ "collectionDate": collection_date,
64
+ }
65
+ bindata["bins"].append(dict_data)
66
+
67
+ for recyclingDate in recycling_dates:
68
+
69
+ collection_date = (
70
+ datetime.strptime(recyclingDate, "%d/%m/%Y")
71
+ + timedelta(days=offset_days)
72
+ ).strftime("%d/%m/%Y")
73
+
74
+ dict_data = {
75
+ "type": "Recycling Bin",
76
+ "collectionDate": collection_date,
77
+ }
78
+ bindata["bins"].append(dict_data)
79
+
80
+ dict_data = {
81
+ "type": "Garden Waste Bin",
82
+ "collectionDate": collection_date,
83
+ }
84
+ bindata["bins"].append(dict_data)
85
+
86
+ for food_date in food_dates:
87
+
88
+ collection_date = (
89
+ datetime.strptime(food_date, "%d/%m/%Y") + timedelta(days=offset_days)
90
+ ).strftime("%d/%m/%Y")
91
+
92
+ dict_data = {
93
+ "type": "Food Waste Bin",
94
+ "collectionDate": collection_date,
95
+ }
96
+ bindata["bins"].append(dict_data)
97
+
98
+ bindata["bins"].sort(
99
+ key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
100
+ )
101
+
102
+ return bindata
@@ -42,14 +42,14 @@ class CouncilClass(AbstractGetBinDataClass):
42
42
  wait = WebDriverWait(driver, 60)
43
43
  address_entry_field = wait.until(
44
44
  EC.presence_of_element_located(
45
- (By.XPATH, '//*[@id="combobox-input-19"]')
45
+ (By.XPATH, '//*[@id="combobox-input-20"]')
46
46
  )
47
47
  )
48
48
 
49
49
  address_entry_field.send_keys(str(full_address))
50
50
 
51
51
  address_entry_field = wait.until(
52
- EC.element_to_be_clickable((By.XPATH, '//*[@id="combobox-input-19"]'))
52
+ EC.element_to_be_clickable((By.XPATH, '//*[@id="combobox-input-20"]'))
53
53
  )
54
54
  address_entry_field.click()
55
55
  address_entry_field.send_keys(Keys.BACKSPACE)
@@ -57,7 +57,7 @@ class CouncilClass(AbstractGetBinDataClass):
57
57
 
58
58
  first_found_address = wait.until(
59
59
  EC.element_to_be_clickable(
60
- (By.XPATH, '//*[@id="dropdown-element-19"]/ul')
60
+ (By.XPATH, '//*[@id="dropdown-element-20"]/ul')
61
61
  )
62
62
  )
63
63
 
@@ -0,0 +1,93 @@
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+
4
+ from uk_bin_collection.uk_bin_collection.common import *
5
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
6
+
7
+
8
+ # import the wonderful Beautiful Soup and the URL grabber
9
+ class CouncilClass(AbstractGetBinDataClass):
10
+ """
11
+ Concrete classes have to implement all abstract operations of the
12
+ base class. They can also override some operations with a default
13
+ implementation.
14
+ """
15
+
16
+ def parse_data(self, page: str, **kwargs) -> dict:
17
+
18
+ user_postcode = kwargs.get("postcode")
19
+ user_paon = kwargs.get("paon")
20
+ check_postcode(user_postcode)
21
+ check_paon(user_paon)
22
+ bindata = {"bins": []}
23
+
24
+ URI = "https://abc-wrp.whitespacews.com/"
25
+
26
+ session = requests.Session()
27
+
28
+ # get link from first page as has some kind of unique hash
29
+ r = session.get(
30
+ URI,
31
+ )
32
+ r.raise_for_status()
33
+ soup = BeautifulSoup(r.text, features="html.parser")
34
+
35
+ alink = soup.find("a", text="View My Collections")
36
+
37
+ if alink is None:
38
+ raise Exception("Initial page did not load correctly")
39
+
40
+ # greplace 'seq' query string to skip next step
41
+ nextpageurl = alink["href"].replace("seq=1", "seq=2")
42
+
43
+ data = {
44
+ "address_name_number": user_paon,
45
+ "address_postcode": user_postcode,
46
+ }
47
+
48
+ # get list of addresses
49
+ r = session.post(nextpageurl, data)
50
+ r.raise_for_status()
51
+
52
+ soup = BeautifulSoup(r.text, features="html.parser")
53
+
54
+ # get first address (if you don't enter enough argument values this won't find the right address)
55
+ alink = soup.find("div", id="property_list").find("a")
56
+
57
+ if alink is None:
58
+ raise Exception("Address not found")
59
+
60
+ nextpageurl = URI + alink["href"]
61
+
62
+ # get collection page
63
+ r = session.get(
64
+ nextpageurl,
65
+ )
66
+ r.raise_for_status()
67
+ soup = BeautifulSoup(r.text, features="html.parser")
68
+
69
+ if soup.find("span", id="waste-hint"):
70
+ raise Exception("No scheduled services at this address")
71
+
72
+ u1s = soup.find("section", id="scheduled-collections").find_all("u1")
73
+
74
+ for u1 in u1s:
75
+ lis = u1.find_all("li", recursive=False)
76
+
77
+ date = lis[1].text.replace("\n", "")
78
+ bin_type = lis[2].text.replace("\n", "")
79
+
80
+ dict_data = {
81
+ "type": bin_type,
82
+ "collectionDate": datetime.strptime(
83
+ date,
84
+ "%d/%m/%Y",
85
+ ).strftime(date_format),
86
+ }
87
+ bindata["bins"].append(dict_data)
88
+
89
+ bindata["bins"].sort(
90
+ key=lambda x: datetime.strptime(x.get("collectionDate"), date_format)
91
+ )
92
+
93
+ return bindata
@@ -30,14 +30,17 @@ class CouncilClass(AbstractGetBinDataClass):
30
30
  # Find each <time> element in the schedule
31
31
  for entry in soup.find_all("time"):
32
32
 
33
- dict_data = {
34
- "type": entry.find(class_="ScheduleItem").text.strip(),
35
- "collectionDate": datetime.strptime(
36
- entry["datetime"],
37
- "%Y-%m-%d",
38
- ).strftime("%d/%m/%Y"),
39
- }
40
- bindata["bins"].append(dict_data)
33
+ ScheduleItems = entry.find_all(class_="ScheduleItem")
34
+
35
+ for ScheduleItem in ScheduleItems:
36
+ dict_data = {
37
+ "type": ScheduleItem.text.strip(),
38
+ "collectionDate": datetime.strptime(
39
+ entry["datetime"],
40
+ "%Y-%m-%d",
41
+ ).strftime("%d/%m/%Y"),
42
+ }
43
+ bindata["bins"].append(dict_data)
41
44
 
42
45
  bindata["bins"].sort(
43
46
  key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
@@ -1,4 +1,5 @@
1
1
  from bs4 import BeautifulSoup
2
+
2
3
  from uk_bin_collection.uk_bin_collection.common import *
3
4
  from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
4
5
 
@@ -45,4 +46,17 @@ class CouncilClass(AbstractGetBinDataClass):
45
46
  }
46
47
  data["bins"].append(dict_data)
47
48
 
49
+ if len(page_text) > 5:
50
+ garden_day = datetime.strptime(
51
+ remove_ordinal_indicator_from_date_string(
52
+ page_text[6].find_next("strong").text
53
+ ),
54
+ "%d %B %Y",
55
+ ).strftime(date_format)
56
+ dict_data = {
57
+ "type": "Garden",
58
+ "collectionDate": garden_day,
59
+ }
60
+ data["bins"].append(dict_data)
61
+
48
62
  return data
@@ -0,0 +1,81 @@
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+
4
+ from uk_bin_collection.uk_bin_collection.common import *
5
+ from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
6
+
7
+
8
+ # import the wonderful Beautiful Soup and the URL grabber
9
+ class CouncilClass(AbstractGetBinDataClass):
10
+ """
11
+ Concrete classes have to implement all abstract operations of the
12
+ base class. They can also override some operations with a default
13
+ implementation.
14
+ """
15
+
16
+ def parse_data(self, page: str, **kwargs) -> dict:
17
+
18
+ user_uprn = kwargs.get("uprn")
19
+ check_uprn(user_uprn)
20
+ bindata = {"bins": []}
21
+
22
+ URI = f"https://service.folkestone-hythe.gov.uk/webapp/myarea/index.php?uprn={user_uprn}"
23
+
24
+ # Make the GET request
25
+ response = requests.get(URI)
26
+
27
+ soup = BeautifulSoup(response.content, "html.parser")
28
+
29
+ soup = soup.find("div", {"id": "bincollections"})
30
+
31
+ # Find the Recycling and Non-Recyclables sections
32
+ bin_schedule = {}
33
+
34
+ # Extract the recycling schedule
35
+ recycling_section = soup.find("span", text=lambda x: x and "Recycling" in x)
36
+ if recycling_section:
37
+ bin_types = recycling_section.text.replace("Recycling: ", "").split(" / ")
38
+ recycling_dates = recycling_section.find_next("ul").find_all("li")
39
+ bin_schedule["Recycling"] = [date.text.strip() for date in recycling_dates]
40
+ for date in recycling_dates:
41
+ for bin_type in bin_types:
42
+ dict_data = {
43
+ "type": bin_type.strip(),
44
+ "collectionDate": datetime.strptime(
45
+ remove_ordinal_indicator_from_date_string(
46
+ date.text.strip()
47
+ ),
48
+ "%A %d %B %Y",
49
+ ).strftime("%d/%m/%Y"),
50
+ }
51
+ bindata["bins"].append(dict_data)
52
+
53
+ # Extract the non-recyclables schedule
54
+ non_recyclables_section = soup.find(
55
+ "span", text=lambda x: x and "Non-Recyclables" in x
56
+ )
57
+ if non_recyclables_section:
58
+ bin_types = non_recyclables_section.text.replace(
59
+ "Non-Recyclables: ", ""
60
+ ).split(" / ")
61
+ non_recyclables_dates = non_recyclables_section.find_next("ul").find_all(
62
+ "li"
63
+ )
64
+ for date in non_recyclables_dates:
65
+ for bin_type in bin_types:
66
+ dict_data = {
67
+ "type": bin_type.strip(),
68
+ "collectionDate": datetime.strptime(
69
+ remove_ordinal_indicator_from_date_string(
70
+ date.text.strip()
71
+ ),
72
+ "%A %d %B %Y",
73
+ ).strftime("%d/%m/%Y"),
74
+ }
75
+ bindata["bins"].append(dict_data)
76
+
77
+ bindata["bins"].sort(
78
+ key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
79
+ )
80
+
81
+ return bindata