|
- import requests
- headers = {
- 'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
- }
- url = 'https://www.sogou.com/web'
- kw = input('请输入需要搜索的词:')
- param = {
- 'query':kw
- }
- response = requests.get(url=url,params=param,headers=headers)
- page_text = response.text
- filename = kw+'.html'
- with open(filename,'w',encoding='utf-8') as fp:
- fp.write(page_text)
- print(filename,'保存成功')
复制代码
|
|