网页返回问题
import requestsurl = 'http://www.biqukan.com/1_1094/5403177.html'
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/86.0.4240.198 Safari/537.36"
}
req = requests.get(url=url, headers=headers)
print(req.read().decode('utf-8'))
text/html;charset=utf-8
没有问题??? requests不用decode,直接用text就可以。
import requests
url = 'http://www.biqukan.com/1_1094/5403177.html'
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/86.0.4240.198 Safari/537.36"
}
r = requests.get(url=url, headers=headers)
print(r.text) suchocolate 发表于 2021-7-20 12:06
requests不用decode,直接用text就可以。
{:7_112:}
页:
[1]