uk_bin_collection 0.152.0__py3-none-any.whl → 0.152.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uk_bin_collection/tests/input.json +92 -58
- uk_bin_collection/uk_bin_collection/councils/AdurAndWorthingCouncils.py +69 -24
- uk_bin_collection/uk_bin_collection/councils/BexleyCouncil.py +24 -47
- uk_bin_collection/uk_bin_collection/councils/CharnwoodBoroughCouncil.py +14 -3
- uk_bin_collection/uk_bin_collection/councils/CheltenhamBoroughCouncil.py +12 -12
- uk_bin_collection/uk_bin_collection/councils/CheshireEastCouncil.py +24 -2
- uk_bin_collection/uk_bin_collection/councils/ChorleyCouncil.py +4 -0
- uk_bin_collection/uk_bin_collection/councils/CroydonCouncil.py +114 -261
- uk_bin_collection/uk_bin_collection/councils/DartfordBoroughCouncil.py +13 -0
- uk_bin_collection/uk_bin_collection/councils/DoverDistrictCouncil.py +17 -2
- uk_bin_collection/uk_bin_collection/councils/EastDevonDC.py +14 -1
- uk_bin_collection/uk_bin_collection/councils/EastbourneBoroughCouncil.py +76 -0
- uk_bin_collection/uk_bin_collection/councils/EastleighBoroughCouncil.py +59 -45
- uk_bin_collection/uk_bin_collection/councils/EnvironmentFirst.py +2 -0
- uk_bin_collection/uk_bin_collection/councils/EppingForestDistrictCouncil.py +47 -15
- uk_bin_collection/uk_bin_collection/councils/GlasgowCityCouncil.py +13 -1
- uk_bin_collection/uk_bin_collection/councils/GuildfordCouncil.py +2 -3
- uk_bin_collection/uk_bin_collection/councils/HerefordshireCouncil.py +13 -2
- uk_bin_collection/uk_bin_collection/councils/HuntingdonDistrictCouncil.py +18 -4
- uk_bin_collection/uk_bin_collection/councils/LewesDistrictCouncil.py +76 -0
- uk_bin_collection/uk_bin_collection/councils/LiverpoolCityCouncil.py +16 -4
- uk_bin_collection/uk_bin_collection/councils/MaidstoneBoroughCouncil.py +42 -47
- uk_bin_collection/uk_bin_collection/councils/NewhamCouncil.py +13 -6
- uk_bin_collection/uk_bin_collection/councils/NorthSomersetCouncil.py +14 -9
- uk_bin_collection/uk_bin_collection/councils/NorthTynesideCouncil.py +2 -2
- uk_bin_collection/uk_bin_collection/councils/NorthumberlandCouncil.py +50 -14
- uk_bin_collection/uk_bin_collection/councils/SouthRibbleCouncil.py +115 -65
- uk_bin_collection/uk_bin_collection/councils/StokeOnTrentCityCouncil.py +10 -5
- uk_bin_collection/uk_bin_collection/councils/TorbayCouncil.py +1 -3
- uk_bin_collection/uk_bin_collection/councils/WakefieldCityCouncil.py +3 -0
- {uk_bin_collection-0.152.0.dist-info → uk_bin_collection-0.152.1.dist-info}/METADATA +1 -1
- {uk_bin_collection-0.152.0.dist-info → uk_bin_collection-0.152.1.dist-info}/RECORD +35 -33
- {uk_bin_collection-0.152.0.dist-info → uk_bin_collection-0.152.1.dist-info}/LICENSE +0 -0
- {uk_bin_collection-0.152.0.dist-info → uk_bin_collection-0.152.1.dist-info}/WHEEL +0 -0
- {uk_bin_collection-0.152.0.dist-info → uk_bin_collection-0.152.1.dist-info}/entry_points.txt +0 -0
@@ -206,13 +206,11 @@
|
|
206
206
|
"LAD24CD": "N09000003"
|
207
207
|
},
|
208
208
|
"BexleyCouncil": {
|
209
|
-
"
|
210
|
-
"postcode": "DA5 3AH",
|
209
|
+
"uprn": "100020196143",
|
211
210
|
"skip_get_url": true,
|
212
211
|
"url": "https://waste.bexley.gov.uk/waste",
|
213
|
-
"web_driver": "http://selenium:4444",
|
214
212
|
"wiki_name": "Bexley",
|
215
|
-
"wiki_note": "
|
213
|
+
"wiki_note": "Provide your UPRN. Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to locate it.",
|
216
214
|
"LAD24CD": "E09000004"
|
217
215
|
},
|
218
216
|
"BirminghamCityCouncil": {
|
@@ -476,10 +474,11 @@
|
|
476
474
|
"LAD24CD": "W06000008"
|
477
475
|
},
|
478
476
|
"CharnwoodBoroughCouncil": {
|
479
|
-
"
|
480
|
-
"
|
477
|
+
"uprn": "100030446438",
|
478
|
+
"skip_get_url": true,
|
479
|
+
"url": "https://www.charnwood.gov.uk/pages/waste_collections_calendars",
|
481
480
|
"wiki_name": "Charnwood",
|
482
|
-
"wiki_note": "
|
481
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
483
482
|
"LAD24CD": "E07000130"
|
484
483
|
},
|
485
484
|
"ChelmsfordCityCouncil": {
|
@@ -508,10 +507,11 @@
|
|
508
507
|
"LAD24CD": "E07000177"
|
509
508
|
},
|
510
509
|
"CheshireEastCouncil": {
|
511
|
-
"
|
512
|
-
"
|
510
|
+
"skip_get_url": true,
|
511
|
+
"uprn": "100012830647",
|
512
|
+
"url": "https://online.cheshireeast.gov.uk/mycollectionday",
|
513
513
|
"wiki_name": "Cheshire East",
|
514
|
-
"wiki_note": "
|
514
|
+
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
|
515
515
|
"LAD24CD": "E06000049"
|
516
516
|
},
|
517
517
|
"CheshireWestAndChesterCouncil": {
|
@@ -543,11 +543,11 @@
|
|
543
543
|
"ChorleyCouncil": {
|
544
544
|
"postcode": "PR6 7PG",
|
545
545
|
"skip_get_url": true,
|
546
|
-
"uprn": "
|
546
|
+
"uprn": "100010382247",
|
547
547
|
"url": "https://myaccount.chorley.gov.uk/wastecollections.aspx",
|
548
548
|
"web_driver": "http://selenium:4444",
|
549
549
|
"wiki_name": "Chorley",
|
550
|
-
"wiki_note": "Chorley needs to be passed both a Postcode & UPRN
|
550
|
+
"wiki_note": "Chorley needs to be passed both a Postcode & UPRN to work. Find this on [FindMyAddress](https://www.findmyaddress.co.uk/search).",
|
551
551
|
"LAD24CD": "E07000118"
|
552
552
|
},
|
553
553
|
"ColchesterCityCouncil": {
|
@@ -644,8 +644,9 @@
|
|
644
644
|
"LAD24CD": "E07000096"
|
645
645
|
},
|
646
646
|
"DartfordBoroughCouncil": {
|
647
|
-
"uprn": "
|
648
|
-
"url": "https://
|
647
|
+
"uprn": "100060861698",
|
648
|
+
"url": "https://www.dartford.gov.uk/waste-recycling/collection-day",
|
649
|
+
"skip_get_url": true,
|
649
650
|
"wiki_name": "Dartford",
|
650
651
|
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
|
651
652
|
"LAD24CD": "E07000107"
|
@@ -690,10 +691,11 @@
|
|
690
691
|
"LAD24CD": "E06000059"
|
691
692
|
},
|
692
693
|
"DoverDistrictCouncil": {
|
693
|
-
"
|
694
|
-
"
|
694
|
+
"uprn": "100060908340",
|
695
|
+
"url": "https://collections.dover.gov.uk/property",
|
696
|
+
"skip_get_url": true,
|
695
697
|
"wiki_name": "Dover",
|
696
|
-
"wiki_note": "
|
698
|
+
"wiki_note": "To get the UPRN, you can use [FindMyAddress](https://www.findmyaddress.co.uk/search).",
|
697
699
|
"LAD24CD": "E07000108"
|
698
700
|
},
|
699
701
|
"DudleyCouncil": {
|
@@ -735,7 +737,15 @@
|
|
735
737
|
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
736
738
|
"LAD24CD": "S12000008"
|
737
739
|
},
|
738
|
-
"
|
740
|
+
"EastbourneBoroughCouncil": {
|
741
|
+
"uprn": "100060011258",
|
742
|
+
"url": "https://www.lewes-eastbourne.gov.uk/article/1158/When-is-my-bin-collection-day",
|
743
|
+
"skip_get_url": true,
|
744
|
+
"wiki_name": "Eastbourne",
|
745
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
746
|
+
"LAD24CD": "E07000061"
|
747
|
+
},
|
748
|
+
"EastCambridgeshireCouncil": {
|
739
749
|
"skip_get_url": true,
|
740
750
|
"uprn": "10002597178",
|
741
751
|
"url": "https://www.eastcambs.gov.uk/",
|
@@ -744,10 +754,11 @@
|
|
744
754
|
"LAD24CD": "E07000009"
|
745
755
|
},
|
746
756
|
"EastDevonDC": {
|
747
|
-
"
|
748
|
-
"
|
757
|
+
"uprn": "010090909915",
|
758
|
+
"url": "https://eastdevon.gov.uk/recycling-and-waste/recycling-waste-information/when-is-my-bin-collected/",
|
759
|
+
"skip_get_url": true,
|
749
760
|
"wiki_name": "East Devon",
|
750
|
-
"wiki_note": "
|
761
|
+
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search).",
|
751
762
|
"LAD24CD": "E07000040"
|
752
763
|
},
|
753
764
|
"EastHertsCouncil": {
|
@@ -820,6 +831,7 @@
|
|
820
831
|
"skip_get_url": true,
|
821
832
|
"uprn": "100060303535",
|
822
833
|
"url": "https://www.eastleigh.gov.uk/waste-bins-and-recycling/collection-dates/your-waste-bin-and-recycling-collections?uprn=",
|
834
|
+
"web_driver": "http://selenium:4444",
|
823
835
|
"wiki_name": "Eastleigh",
|
824
836
|
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search).",
|
825
837
|
"LAD24CD": "E07000086"
|
@@ -860,9 +872,10 @@
|
|
860
872
|
"EppingForestDistrictCouncil": {
|
861
873
|
"postcode": "IG9 6EP",
|
862
874
|
"url": "https://eppingforestdc.maps.arcgis.com/apps/instant/lookup/index.html?appid=bfca32b46e2a47cd9c0a84f2d8cdde17&find=IG9%206EP",
|
875
|
+
"skip_get_url": true,
|
863
876
|
"web_driver": "http://selenium:4444",
|
864
877
|
"wiki_name": "Epping Forest",
|
865
|
-
"wiki_note": "
|
878
|
+
"wiki_note": "Add your postcode.",
|
866
879
|
"LAD24CD": "E07000072"
|
867
880
|
},
|
868
881
|
"EpsomandEwellBoroughCouncil": {
|
@@ -981,10 +994,11 @@
|
|
981
994
|
"LAD24CD": "E07000173"
|
982
995
|
},
|
983
996
|
"GlasgowCityCouncil": {
|
984
|
-
"
|
985
|
-
"
|
997
|
+
"uprn": "906700034497",
|
998
|
+
"url": "https://onlineservices.glasgow.gov.uk/forms/RefuseAndRecyclingWebApplication/AddressSearch.aspx",
|
999
|
+
"skip_get_url": true,
|
986
1000
|
"wiki_name": "Glasgow City",
|
987
|
-
"wiki_note": "
|
1001
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
988
1002
|
"LAD24CD": "S12000049"
|
989
1003
|
},
|
990
1004
|
"GloucesterCityCouncil": {
|
@@ -1003,21 +1017,21 @@
|
|
1003
1017
|
"wiki_name": "Google Calendar (Public)",
|
1004
1018
|
"wiki_note": "The URL should be the public ics file URL for the public Google calendar. See https://support.google.com/calendar/answer/37083?sjid=7202815583021446882-EU. Councils that currently need this are Trafford.",
|
1005
1019
|
"supported_councils": [
|
1006
|
-
"
|
1007
|
-
"
|
1008
|
-
"
|
1009
|
-
"
|
1010
|
-
"
|
1011
|
-
"
|
1012
|
-
"
|
1013
|
-
"
|
1014
|
-
"
|
1015
|
-
"
|
1016
|
-
"
|
1017
|
-
"
|
1018
|
-
"
|
1019
|
-
"
|
1020
|
-
"
|
1020
|
+
"Trafford",
|
1021
|
+
"Clackmannanshire",
|
1022
|
+
"Havant",
|
1023
|
+
"North Warwickshire",
|
1024
|
+
"Newry and Mourne",
|
1025
|
+
"East Dunbartonshire",
|
1026
|
+
"Pendle",
|
1027
|
+
"Torfaen",
|
1028
|
+
"East Hampshire",
|
1029
|
+
"Ribble Valley",
|
1030
|
+
"Brentwood",
|
1031
|
+
"Isle of Wight",
|
1032
|
+
"Westmorland and Furness",
|
1033
|
+
"Derry City and Strabane",
|
1034
|
+
"Norwich"
|
1021
1035
|
],
|
1022
1036
|
"supported_councils_LAD24CD": [
|
1023
1037
|
"E06000046",
|
@@ -1054,14 +1068,13 @@
|
|
1054
1068
|
"LAD24CD": "E07000145"
|
1055
1069
|
},
|
1056
1070
|
"GuildfordCouncil": {
|
1057
|
-
"house_number": "THE LODGE
|
1071
|
+
"house_number": "THE LODGE",
|
1058
1072
|
"postcode": "GU3 1AH",
|
1059
1073
|
"skip_get_url": true,
|
1060
|
-
"uprn": "100061372691",
|
1061
1074
|
"url": "https://my.guildford.gov.uk/customers/s/view-bin-collections",
|
1062
1075
|
"web_driver": "http://selenium:4444",
|
1063
1076
|
"wiki_name": "Guildford",
|
1064
|
-
"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'.
|
1077
|
+
"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'.",
|
1065
1078
|
"LAD24CD": "E07000209"
|
1066
1079
|
},
|
1067
1080
|
"GwyneddCouncil": {
|
@@ -1137,10 +1150,11 @@
|
|
1137
1150
|
"LAD24CD": "E07000062"
|
1138
1151
|
},
|
1139
1152
|
"HerefordshireCouncil": {
|
1140
|
-
"
|
1141
|
-
"
|
1153
|
+
"uprn": "200002618844",
|
1154
|
+
"url": "https://www.herefordshire.gov.uk/rubbish-recycling/check-bin-collection-day",
|
1155
|
+
"skip_get_url": true,
|
1142
1156
|
"wiki_name": "Herefordshire",
|
1143
|
-
"wiki_note": "
|
1157
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
1144
1158
|
"LAD24CD": "E06000019"
|
1145
1159
|
},
|
1146
1160
|
"HertsmereBoroughCouncil": {
|
@@ -1207,11 +1221,12 @@
|
|
1207
1221
|
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
1208
1222
|
},
|
1209
1223
|
"HuntingdonDistrictCouncil": {
|
1224
|
+
"uprn": "10012048679",
|
1210
1225
|
"LAD24CD": "E07000011",
|
1211
|
-
"url": "http://www.huntingdonshire.gov.uk/refuse-calendar/
|
1212
|
-
"
|
1226
|
+
"url": "http://www.huntingdonshire.gov.uk/refuse-calendar/",
|
1227
|
+
"skip_get_url": true,
|
1213
1228
|
"wiki_name": "Huntingdonshire",
|
1214
|
-
"wiki_note": "
|
1229
|
+
"wiki_note": "Pass the UPRN. You can find it using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
|
1215
1230
|
},
|
1216
1231
|
"HyndburnBoroughCouncil": {
|
1217
1232
|
"postcode": "BB1 4DJ",
|
@@ -1298,6 +1313,14 @@
|
|
1298
1313
|
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
1299
1314
|
"LAD24CD": "E06000016"
|
1300
1315
|
},
|
1316
|
+
"LewesDistrictCouncil": {
|
1317
|
+
"uprn": "100061930155",
|
1318
|
+
"url": "https://www.lewes-eastbourne.gov.uk/article/1158/When-is-my-bin-collection-day",
|
1319
|
+
"skip_get_url": true,
|
1320
|
+
"wiki_name": "Lewes",
|
1321
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
1322
|
+
"LAD24CD": "E07000063"
|
1323
|
+
},
|
1301
1324
|
"LichfieldDistrictCouncil": {
|
1302
1325
|
"uprn": "100031694085",
|
1303
1326
|
"url": "https://www.lichfielddc.gov.uk",
|
@@ -1325,10 +1348,11 @@
|
|
1325
1348
|
"LAD24CD": "N09000007"
|
1326
1349
|
},
|
1327
1350
|
"LiverpoolCityCouncil": {
|
1328
|
-
"
|
1329
|
-
"
|
1351
|
+
"uprn": "38164600",
|
1352
|
+
"skip_get_url": true,
|
1353
|
+
"url": "https://liverpool.gov.uk/bins-and-recycling/bin-collections/",
|
1330
1354
|
"wiki_name": "Liverpool",
|
1331
|
-
"wiki_note": "
|
1355
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
1332
1356
|
"LAD24CD": "E08000012"
|
1333
1357
|
},
|
1334
1358
|
"LondonBoroughEaling": {
|
@@ -1414,6 +1438,15 @@
|
|
1414
1438
|
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.",
|
1415
1439
|
"LAD24CD": "E06000032"
|
1416
1440
|
},
|
1441
|
+
"MaidstoneBoroughCouncil": {
|
1442
|
+
"skip_get_url": true,
|
1443
|
+
"house_number": "71",
|
1444
|
+
"postcode": "ME16 8BT",
|
1445
|
+
"url": "https://my.maidstone.gov.uk/service/Find-your-bin-day",
|
1446
|
+
"wiki_name": "Maidstone",
|
1447
|
+
"wiki_note": "Pass the house number and postcode in their respective parameters. This parser requires a Selenium webdriver.",
|
1448
|
+
"LAD24CD": "E07000110"
|
1449
|
+
},
|
1417
1450
|
"MaldonDistrictCouncil": {
|
1418
1451
|
"skip_get_url": true,
|
1419
1452
|
"uprn": "100090557253",
|
@@ -1584,8 +1617,9 @@
|
|
1584
1617
|
"LAD24CD": "E07000091"
|
1585
1618
|
},
|
1586
1619
|
"NewarkAndSherwoodDC": {
|
1587
|
-
"
|
1588
|
-
"
|
1620
|
+
"uprn": "200004258529",
|
1621
|
+
"url": "https://app.newark-sherwooddc.gov.uk/bincollection/",
|
1622
|
+
"skip_get_url": true,
|
1589
1623
|
"wiki_name": "Newark and Sherwood",
|
1590
1624
|
"wiki_note": "Replace XXXXXXXX with your UPRN.",
|
1591
1625
|
"LAD24CD": "E07000175"
|
@@ -1605,10 +1639,11 @@
|
|
1605
1639
|
"LAD24CD": "E07000195"
|
1606
1640
|
},
|
1607
1641
|
"NewhamCouncil": {
|
1608
|
-
"
|
1609
|
-
"
|
1642
|
+
"uprn": "46077811",
|
1643
|
+
"url": "https://bincollection.newham.gov.uk/",
|
1644
|
+
"skip_get_url": true,
|
1610
1645
|
"wiki_name": "Newham",
|
1611
|
-
"wiki_note": "
|
1646
|
+
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
|
1612
1647
|
"LAD24CD": "E09000025"
|
1613
1648
|
},
|
1614
1649
|
"NewportCityCouncil": {
|
@@ -2323,7 +2358,6 @@
|
|
2323
2358
|
"SwindonBoroughCouncil": {
|
2324
2359
|
"uprn": "10022793351",
|
2325
2360
|
"url": "https://www.swindon.gov.uk",
|
2326
|
-
"wiki_command_url_override": "https://www.swindon.gov.uk",
|
2327
2361
|
"wiki_name": "Swindon",
|
2328
2362
|
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN.",
|
2329
2363
|
"LAD24CD": "E06000030"
|
@@ -1,41 +1,86 @@
|
|
1
|
-
import
|
1
|
+
from datetime import datetime
|
2
|
+
|
2
3
|
from bs4 import BeautifulSoup
|
3
|
-
|
4
|
+
|
5
|
+
from uk_bin_collection.uk_bin_collection.common import (
|
6
|
+
date_format,
|
7
|
+
get_date_with_ordinal,
|
8
|
+
)
|
4
9
|
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
5
10
|
|
6
11
|
|
7
|
-
# import the wonderful Beautiful Soup and the URL grabber
|
8
12
|
class CouncilClass(AbstractGetBinDataClass):
|
9
|
-
"""
|
10
|
-
Concrete classes have to implement all abstract operations of the
|
11
|
-
base class. They can also override some operations with a default
|
12
|
-
implementation.
|
13
|
-
"""
|
14
|
-
|
15
13
|
def parse_data(self, page: str, **kwargs) -> dict:
|
16
|
-
#
|
17
|
-
|
18
|
-
|
14
|
+
# Handle both string and Response objects
|
15
|
+
page_content = page.text if hasattr(page, "text") else page
|
16
|
+
|
17
|
+
soup = BeautifulSoup(page_content, features="html.parser")
|
19
18
|
|
20
19
|
data = {"bins": []}
|
21
20
|
collections = []
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
# Find all bin collection rows
|
23
|
+
bin_rows = soup.find_all("div", class_="bin-collection-listing-row")
|
24
|
+
|
25
|
+
if not bin_rows:
|
26
|
+
raise ValueError("No bin collection rows found in HTML")
|
27
|
+
|
28
|
+
for bin_row in bin_rows:
|
29
|
+
try:
|
30
|
+
# Get bin type from h2
|
31
|
+
bin_type_elem = bin_row.find("h2")
|
32
|
+
if not bin_type_elem:
|
33
|
+
continue
|
34
|
+
bin_type = bin_type_elem.text.strip()
|
35
|
+
|
36
|
+
# Find next collection date - look for all <p> tags
|
37
|
+
paragraphs = bin_row.find_all("p")
|
38
|
+
|
39
|
+
for p in paragraphs:
|
40
|
+
if p.get_text() and "Next collection:" in p.get_text():
|
41
|
+
date_str = p.get_text().replace("Next collection:", "").strip()
|
42
|
+
# Extract day number from date string (e.g. "2" from "Friday 2nd May")
|
43
|
+
day_number = int("".join(filter(str.isdigit, date_str)))
|
44
|
+
# Replace ordinal in date string with plain number
|
45
|
+
date_str = date_str.replace(
|
46
|
+
get_date_with_ordinal(day_number), str(day_number)
|
47
|
+
)
|
48
|
+
|
49
|
+
try:
|
50
|
+
# Parse date with full format
|
51
|
+
bin_date = datetime.strptime(date_str, "%A %d %B")
|
52
|
+
|
53
|
+
# Add current year since it's not in the date string
|
54
|
+
current_year = datetime.now().year
|
55
|
+
bin_date = bin_date.replace(year=current_year)
|
56
|
+
|
57
|
+
# If the date is in the past, it's probably for next year
|
58
|
+
if bin_date < datetime.now():
|
59
|
+
bin_date = bin_date.replace(year=current_year + 1)
|
60
|
+
|
61
|
+
collections.append((bin_type, bin_date))
|
62
|
+
print(
|
63
|
+
f"Successfully parsed date for {bin_type}: {bin_date}"
|
64
|
+
)
|
65
|
+
break
|
66
|
+
|
67
|
+
except ValueError as e:
|
68
|
+
print(
|
69
|
+
f"Failed to parse date '{date_str}' for {bin_type}: {e}"
|
70
|
+
)
|
71
|
+
continue
|
72
|
+
|
73
|
+
except Exception as e:
|
74
|
+
print(f"Error processing bin row: {e}")
|
75
|
+
continue
|
76
|
+
|
77
|
+
if not collections:
|
78
|
+
raise ValueError("No valid collection dates found")
|
34
79
|
|
35
80
|
ordered_data = sorted(collections, key=lambda x: x[1])
|
36
81
|
for item in ordered_data:
|
37
82
|
dict_data = {
|
38
|
-
"type": item[0]
|
83
|
+
"type": item[0],
|
39
84
|
"collectionDate": item[1].strftime(date_format),
|
40
85
|
}
|
41
86
|
data["bins"].append(dict_data)
|
@@ -24,74 +24,51 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
24
24
|
def parse_data(self, page: str, **kwargs) -> dict:
|
25
25
|
driver = None
|
26
26
|
try:
|
27
|
-
page = "https://waste.bexley.gov.uk/waste"
|
28
|
-
|
29
|
-
data = {"bins": []}
|
30
|
-
|
31
27
|
user_uprn = kwargs.get("uprn")
|
32
|
-
user_paon = kwargs.get("paon")
|
33
|
-
user_postcode = kwargs.get("postcode")
|
34
28
|
web_driver = kwargs.get("web_driver")
|
35
29
|
headless = kwargs.get("headless")
|
36
30
|
|
31
|
+
page = f"https://waste.bexley.gov.uk/waste/{user_uprn}"
|
32
|
+
|
33
|
+
print(f"Trying URL: {page}") # Debug
|
34
|
+
|
37
35
|
# Create Selenium webdriver
|
38
36
|
driver = create_webdriver(web_driver, headless, None, __name__)
|
39
37
|
driver.get(page)
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
inputElement_postcodesearch = wait.until(
|
44
|
-
EC.element_to_be_clickable((By.ID, "pc"))
|
45
|
-
)
|
46
|
-
inputElement_postcodesearch.send_keys(user_postcode)
|
47
|
-
|
48
|
-
find_address_btn = wait.until(
|
49
|
-
EC.element_to_be_clickable((By.XPATH, '//*[@id="sub"]'))
|
50
|
-
)
|
51
|
-
find_address_btn.click()
|
39
|
+
# Wait for the main content container to be present
|
40
|
+
wait = WebDriverWait(driver, 30) # Increased timeout to 30 seconds
|
52
41
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
dropdown_options.click()
|
58
|
-
time.sleep(1)
|
59
|
-
|
60
|
-
# Wait for the element to be clickable
|
61
|
-
address = WebDriverWait(driver, 10).until(
|
62
|
-
EC.element_to_be_clickable(
|
63
|
-
(By.XPATH, f'//li[contains(text(), "{user_paon}")]')
|
42
|
+
# First wait for container
|
43
|
+
main_content = wait.until(
|
44
|
+
EC.presence_of_element_located(
|
45
|
+
(By.XPATH, "/html/body/div[1]/div/div[2]/div")
|
64
46
|
)
|
65
47
|
)
|
66
48
|
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
submit_address = wait.until(
|
71
|
-
EC.presence_of_element_located((By.XPATH, '//*[@id="go"]'))
|
72
|
-
)
|
73
|
-
time.sleep(2)
|
74
|
-
submit_address.click()
|
49
|
+
# Then wait for loading indicator to disappear
|
50
|
+
wait.until(EC.invisibility_of_element_located((By.ID, "loading-indicator")))
|
75
51
|
|
76
|
-
|
77
|
-
|
78
|
-
(By.XPATH, '//h1[contains(text(), "Your bin days")]')
|
79
|
-
)
|
80
|
-
)
|
52
|
+
# Add after the loading indicator wait
|
53
|
+
time.sleep(3) # Give extra time for JavaScript to populate the data
|
81
54
|
|
82
|
-
|
83
|
-
|
55
|
+
# Then wait for at least one bin section to appear
|
56
|
+
wait.until(
|
57
|
+
EC.presence_of_element_located((By.CLASS_NAME, "waste-service-name"))
|
84
58
|
)
|
85
59
|
|
60
|
+
# Now parse the page content
|
86
61
|
soup = BeautifulSoup(driver.page_source, features="html.parser")
|
87
62
|
|
88
|
-
# Find all waste services
|
89
|
-
|
90
|
-
# Initialize the data dictionary
|
91
63
|
data = {"bins": []}
|
92
64
|
bin_sections = soup.find_all("h3", class_="waste-service-name")
|
93
65
|
|
94
|
-
|
66
|
+
if not bin_sections:
|
67
|
+
print("No bin sections found after waiting for content")
|
68
|
+
print(f"Page source: {driver.page_source}")
|
69
|
+
return data
|
70
|
+
|
71
|
+
# Rest of your existing bin processing code
|
95
72
|
for bin_section in bin_sections:
|
96
73
|
# Extract the bin type (e.g., "Brown Caddy", "Green Wheelie Bin", etc.)
|
97
74
|
bin_type = bin_section.get_text(strip=True).split("\n")[
|
@@ -1,10 +1,11 @@
|
|
1
|
+
from datetime import timedelta
|
2
|
+
|
1
3
|
from bs4 import BeautifulSoup
|
4
|
+
from dateutil.relativedelta import relativedelta
|
5
|
+
|
2
6
|
from uk_bin_collection.uk_bin_collection.common import *
|
3
7
|
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
|
4
8
|
|
5
|
-
from datetime import timedelta
|
6
|
-
from dateutil.relativedelta import relativedelta
|
7
|
-
|
8
9
|
|
9
10
|
# import the wonderful Beautiful Soup and the URL grabber
|
10
11
|
class CouncilClass(AbstractGetBinDataClass):
|
@@ -15,7 +16,17 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
15
16
|
"""
|
16
17
|
|
17
18
|
def parse_data(self, page: str, **kwargs) -> dict:
|
19
|
+
try:
|
20
|
+
user_uprn = kwargs.get("uprn")
|
21
|
+
check_uprn(user_uprn)
|
22
|
+
url = f"https://my.charnwood.gov.uk/location?put=cbc{user_uprn}&rememberme=0&redirect=%2F"
|
23
|
+
if not user_uprn:
|
24
|
+
url = kwargs.get("url")
|
25
|
+
except Exception as e:
|
26
|
+
raise ValueError(f"Error getting identifier: {str(e)}")
|
27
|
+
|
18
28
|
# Make a BS4 object
|
29
|
+
page = requests.get(url)
|
19
30
|
soup = BeautifulSoup(page.text, features="html.parser")
|
20
31
|
soup.prettify()
|
21
32
|
|
@@ -266,9 +266,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
266
266
|
).date()
|
267
267
|
|
268
268
|
for refuse_date in refuse_dates:
|
269
|
-
collection_date = datetime.strptime(refuse_date, "%d/%m/%Y") + timedelta(
|
269
|
+
collection_date = (datetime.strptime(refuse_date, "%d/%m/%Y") + timedelta(
|
270
270
|
days=refuse_day_offset
|
271
|
-
)
|
271
|
+
)).date()
|
272
272
|
if collection_date in bh_dict:
|
273
273
|
collection_date = bh_dict[collection_date]
|
274
274
|
collection_date = collection_date.strftime("%d/%m/%Y")
|
@@ -281,9 +281,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
281
281
|
|
282
282
|
for recycling_date in recycling_dates:
|
283
283
|
|
284
|
-
collection_date = datetime.strptime(recycling_date, "%d/%m/%Y") + timedelta(
|
284
|
+
collection_date = (datetime.strptime(recycling_date, "%d/%m/%Y") + timedelta(
|
285
285
|
days=recycling_day_offset
|
286
|
-
)
|
286
|
+
)).date()
|
287
287
|
if collection_date in bh_dict:
|
288
288
|
collection_date = bh_dict[collection_date]
|
289
289
|
collection_date = collection_date.strftime("%d/%m/%Y")
|
@@ -296,9 +296,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
296
296
|
|
297
297
|
for garden_date in garden_dates:
|
298
298
|
|
299
|
-
collection_date = datetime.strptime(garden_date, "%d/%m/%Y") + timedelta(
|
299
|
+
collection_date = (datetime.strptime(garden_date, "%d/%m/%Y") + timedelta(
|
300
300
|
days=garden_day_offset
|
301
|
-
)
|
301
|
+
)).date()
|
302
302
|
if collection_date in bh_dict:
|
303
303
|
collection_date = bh_dict[collection_date]
|
304
304
|
collection_date = collection_date.strftime("%d/%m/%Y")
|
@@ -318,9 +318,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
318
318
|
|
319
319
|
for food_date in food_dates:
|
320
320
|
|
321
|
-
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
321
|
+
collection_date = (datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
322
322
|
days=food_day_offset
|
323
|
-
)
|
323
|
+
)).date()
|
324
324
|
if collection_date in bh_dict:
|
325
325
|
collection_date = bh_dict[collection_date]
|
326
326
|
collection_date = collection_date.strftime("%d/%m/%Y")
|
@@ -354,9 +354,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
354
354
|
|
355
355
|
for food_date in food_dates_first:
|
356
356
|
|
357
|
-
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
357
|
+
collection_date = (datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
358
358
|
days=food_day_offset
|
359
|
-
)
|
359
|
+
)).date()
|
360
360
|
if collection_date in bh_dict:
|
361
361
|
collection_date = bh_dict[collection_date]
|
362
362
|
collection_date = collection_date.strftime("%d/%m/%Y")
|
@@ -368,9 +368,9 @@ class CouncilClass(AbstractGetBinDataClass):
|
|
368
368
|
bindata["bins"].append(dict_data)
|
369
369
|
for food_date in food_dates_second:
|
370
370
|
|
371
|
-
collection_date = datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
371
|
+
collection_date = (datetime.strptime(food_date, "%d/%m/%Y") + timedelta(
|
372
372
|
days=second_week_offset
|
373
|
-
)
|
373
|
+
)).date()
|
374
374
|
if collection_date in bh_dict:
|
375
375
|
collection_date = bh_dict[collection_date]
|
376
376
|
collection_date = collection_date.strftime("%d/%m/%Y")
|