Skip to content

Commit 441b15b

Browse files
committed
fix: Adding headers to requests
1 parent 377cf74 commit 441b15b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Classes/digikey.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ def SetURL(self, url):
3939

4040
#Start gathering data
4141
def StartScrape(self):
42-
self.page = requests.get(self.url)
42+
custom_header = {
43+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
44+
'ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
45+
'ACCEPT_ENCODING': 'gzip, deflate',
46+
'ACCEPT_LANGUAGE': 'en-US,en;q=0.9',
47+
'REFERER': 'https://www.google.com/',
48+
}
49+
self.page = requests.get(self.url, headers = custom_header)
4350
self.tree = html.fromstring(self.page.content)
4451

4552

0 commit comments

Comments
 (0)