学习爬虫遇到解析问题,爬取一个网站出现gbk问题,求指点。才学习爬虫不知道怎么处理这个问题。
代码:import requests
url = "https://www.xxxxx.html"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
}
resp = requests.post(url, headers=headers)
print(resp.text)
报错:Traceback (most recent call last):
File "D:\pythonProject\jjj.py", line 12, in
print(resp.text)
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 26428: illegal multibyte sequence