我的第一个爬虫
import requests
#第一个爬虫项目
kw = {'wd':'12306'}
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3"}
reponse = requests.get('https://www.baidu.com/s',params=kw,headers=headers)
data = reponse.content.decode()
print(reponse.url)
with open('./spider/baidu.html','w') as f:
f.write(data)