在使用requests爬取文章的时候总是发现其中显示的中文全是乱码
参考了一篇博客
参考文章:https://www.cnblogs.com/bw13/p/6549248.html
原因是因为网页有自己本省自己的编码方式
可以通过这种方式一步解决:
responece = requests.post(url=url_check, headers=headers, data=data)
f.close()
responece.encoding = responece.apparent_encoding
with open("output.html","w+",encoding=responece.encoding) as f:
f.write(responece.text)
f.close()
print(responece.text)