import requests header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36'} url = 'https://www.sogou.com/web' kw = input('你想搜啥:') param = {'query':kw} response = requests.get(url=url,params=param,headers=header) page_text = response.text field_name = kw+'.html' with open(field_name,'w',encoding='UTF-8') as Du: Du.write(page_text) print(field_name,'结束战斗!')
实现搜狗网页代码小采集
来源:https://www.cnblogs.com/sucanji/p/10829222.html