百度360搜索关键词提交.py(亲测有效)
import requests keyword = "Python" try: kv = {'wd':keyword} # 百度 kv1 = {'q':keyword} # 360 r = requests.get("http://www.baidu.com/s",params=kv) # 百度 r1 = requests.get("http://www.so.com/s",params=kv1) # 360 print("百度:",r.request.url) print("360:", r1.request.url) r.raise_for_status() #如果状态不是200,引发HTTPError异常 r1.raise_for_status() # 如果状态不是200,引发HTTPError异常 print(len(r.text)) print(len(r1.text)) except: print("产生异常")