Add header to get content type
This commit is contained in:
parent
e506804666
commit
9a279d44b1
|
@ -64,8 +64,11 @@ def get_article(url):
|
||||||
|
|
||||||
def get_content_type(url):
|
def get_content_type(url):
|
||||||
try:
|
try:
|
||||||
headers = {'User-Agent': 'Twitterbot/1.0'}
|
headers = {
|
||||||
return requests.get(url, headers=headers, timeout=2).headers['content-type']
|
'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
||||||
|
'X-Forwarded-For': '66.249.66.1',
|
||||||
|
}
|
||||||
|
return requests.get(url, headers=headers, timeout=5).headers['content-type']
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user