jtguve 2020-06-04
"""百度搜索关键词提交""" import requests url = "https://www.baidu.com/s" keyword = "Python" try: kv = {‘wd‘: ‘keyword‘} r = requests.get(url, params=kv) # https://www.baidu.com/s?wd=Python print(r.request.url) r.raise_for_status() # 1469 r.encoding = r.apparent_encoding print(len(r.text)) # print(r.text) except: print("爬取失败")
"""百度360搜索关键词提交""" import requests url = "https://www.so.com/s" keyword = "Python" try: kv = {‘q‘: ‘keyword‘} r = requests.get(url, params=kv) # https://www.so.com/s?q=keyword print(r.request.url) r.raise_for_status() r.encoding = r.apparent_encoding print(len(r.text)) # 330288 print(r.text[:1000]) except: print("爬取失败")