28.爬虫
import requests url="https://www.qq.com" response=requests.get(url=url) page_text=response.text with open("三刷爬虫/qq.html","w") as f : f.write(page_text) #打印可以正常显示,但是存储到html以后,打开会出现乱码 import requests url="https://www.qq.com" response=requests.get(url=url) page_text=response.content with open("三刷爬虫/qq.html","wb") as f : f.write(page_text) # 响应值对象由text 字符串,改成content 二进制,wb模式写入,打开html会正常显示
text 字符串
content 二进制 bytes
json