Skip to content

Commit 5375210

Browse files
committed
fix: Nuneaton Bedworth Borough Council
fix: #1514
1 parent cc6d038 commit 5375210

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

uk_bin_collection/uk_bin_collection/councils/NuneatonBedworthBoroughCouncil.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1+
import re
2+
import urllib.parse
3+
4+
import requests
15
from bs4 import BeautifulSoup
6+
27
from uk_bin_collection.uk_bin_collection.common import *
38
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass
49

5-
from bs4 import BeautifulSoup
6-
import urllib.parse
7-
import requests
8-
import re
9-
1010

1111
class CouncilClass(AbstractGetBinDataClass):
1212
def parse_data(self, page: str, **kwargs) -> dict:
1313

1414
data = {"bins": []}
1515

16+
headers = {
17+
"Origin": "https://www.nuneatonandbedworth.gov.uk/",
18+
"Referer": "https://www.nuneatonandbedworth.gov.uk/",
19+
"User-Agent": "Mozilla/5.0",
20+
}
21+
1622
street = urllib.parse.quote_plus(kwargs.get("paon"))
1723
base_url = "https://www.nuneatonandbedworth.gov.uk/"
1824
search_query = f"directory/search?directoryID=3&showInMap=&keywords={street}&search=Search+directory"
1925

20-
search_response = requests.get(base_url + search_query)
26+
search_response = requests.get(base_url + search_query, headers=headers)
2127

2228
if search_response.status_code == 200:
2329
soup = BeautifulSoup(search_response.content, "html.parser")
@@ -56,7 +62,13 @@ def parse_data(self, page: str, **kwargs) -> dict:
5662

5763
def get_bin_data(self, url) -> dict:
5864

59-
bin_day_response = requests.get(url)
65+
headers = {
66+
"Origin": "https://www.nuneatonandbedworth.gov.uk/",
67+
"Referer": "https://www.nuneatonandbedworth.gov.uk/",
68+
"User-Agent": "Mozilla/5.0",
69+
}
70+
71+
bin_day_response = requests.get(url, headers=headers)
6072

6173
if bin_day_response.status_code == 200:
6274

0 commit comments

Comments
 (0)