标签:搜索 odi port inf src tps 百度搜索 360搜索 get
1 """百度搜索关键词提交""" 2 3 4 import requests 5 6 url = "https://www.baidu.com/s" 7 keyword = "Python" 8 try: 9 kv = {‘wd‘: ‘keyword‘} 10 r = requests.get(url, params=kv) 11 # https://www.baidu.com/s?wd=Python 12 print(r.request.url) 13 r.raise_for_status() # 1469 14 r.encoding = r.apparent_encoding 15 print(len(r.text)) # 16 print(r.text) 17 except: 18 print("爬取失败")
1 """百度360搜索关键词提交""" 2 3 import requests 4 5 url = "https://www.so.com/s" 6 keyword = "Python" 7 try: 8 kv = {‘q‘: ‘keyword‘} 9 r = requests.get(url, params=kv) 10 # https://www.so.com/s?q=keyword 11 print(r.request.url) 12 r.raise_for_status() 13 r.encoding = r.apparent_encoding 14 print(len(r.text)) # 330288 15 print(r.text[:1000]) 16 except: 17 print("爬取失败")
标签:搜索 odi port inf src tps 百度搜索 360搜索 get
原文地址:https://www.cnblogs.com/sruzzg/p/13041898.html