标签:https windows arc ppa head insecure chardet ica filter
import requests
headers = {
‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36‘
}
url = ‘https://search.jd.com/Search?keyword=%E7%AC%94%E8%AE%B0%E6%9C%AC&enc=utf-8&wq=%E7%AC%94%E8%AE%B0%E6%9C%AC‘
res = requests.get(url,headers=headers)
res.encoding = res.apparent_encoding
print(res.text)
import chardet
import requests
headers = {
‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36‘
}
url = ‘https://search.jd.com/Search?keyword=%E7%AC%94%E8%AE%B0%E6%9C%AC&enc=utf-8&wq=%E7%AC%94%E8%AE%B0%E6%9C%AC‘
res = requests.get(url,headers=headers)
res.encoding =chardet.detect(res.content)[‘encoding‘]
print(res.text)
print(res.encoding)
使用 verify=False 会提示不安全警告
InsecureRequestWarning: Unverified HTTPS request is being made to host ‘api.growingio.com‘. Adding certificate verification is strongly advised. See:
import warnings
warnings.filterwarnings("ignore")
标签:https windows arc ppa head insecure chardet ica filter
原文地址:https://www.cnblogs.com/zl158218/p/13194521.html