-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlDownloader.py
More file actions
16 lines (14 loc) · 530 Bytes
/
HtmlDownloader.py
File metadata and controls
16 lines (14 loc) · 530 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import requests
class HtmlDownloader():
def download(self,url,text):
if url is None:
return None
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
headers={"User-Agent":user_agent}
r = requests.get(url,headers=headers)
if r.status_code==200:
if text:
return r.text
else:
return r.content
return None