No scrambled characters
with open('e:/test.html','w',encoding='utf-8') as f:
f.write(r.text)

The name of the website cannot be written down or it will be considered an infringement and will not be published. Crawl out of the web source code is a piece of garbled
code(the original file has been deleted) :
import requests
url='https://www.douban.com'
headers={中间是什么忘了,总之包含了User-agent和Referer}
r=requests.get(url,headers=headers)
r.text.encode('utf=8')
print(r.statu_code)
print(r.text)
successful access, r.text is a big piece of garbled code?
The original file of crawling a website has been deleted for me, in the same way to visit another website home page is a part of garbled code, with a browser to look at the source code, found that most of the garbled parts seem to be in quotes
write r.text into the html file(utf-8 to gbk) :
< div class = "aw - list - img >
encode('gbk') can't convert
and I modified this program to go to the front page of a video site,
https://www.bilibili.com
with the introduction of several online backsliding, out of only a small piece, is the source code really this point, or it set up other backsliding?
0 Answer
No scrambled characters
with open('e:/test.html','w',encoding='utf-8') as f:
f.write(r.text)
这家伙很懒,什么都没留下...