百度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("产生异常")

 

posted on 2020-12-30 20:51  打篮球的Curry  阅读(133)  评论(0编辑  收藏  举报