import requests import re import os import sys main_url = "https://blog.csdn.net/m0_54218263" headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.62" } res = requests.get(url=main_url, headers=headers) # print(res.content.decode()) print(os.getcwd() + "crawlercrawlering_basic") f = open(os.getcwd() + "crawlercrawlering_basic" + "\test1.html", "w+", encoding="utf-8") # 在记录中文的时候,一定要输入utf-8,也就是需要输入encoding=utf-8. f.write(res.content.decode()) f.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)