在百度搜索引擎中以"Python"为关键词 代码框架: 1 import requests 2 Keyword = " Python " 3 try : 4 kv = { ‘ wd ‘ :Keyword} 5 r = requests.get( " http://www.baidu.com/s " ,params= kv) 6 print (r.request.url) 7 r.raise_for
在百度搜索引擎中以"Python"为关键词
代码框架:
1 import requests 2 Keyword = "Python" 3 try: 4 kv = {‘wd‘:Keyword} 5 r = requests.get("http://www.baidu.com/s",params=kv) 6 print(r.request.url) 7 r.raise_for_status() 8 print(len(r.text)) 9 except: 10 print("爬取失败")
输出:
http://www.baidu.com/s?wd=Python
461379
在360搜索引擎中以"Python"为关键词:
代码框架:
1 import requests 2 Keyword = "Python" 3 try: 4 kv = {‘q‘:Keyword} 5 r = requests.get("http://www.so.com/s",params=kv) 6 print(r.request.url) 7 r.raise_for_status() 8 print(len(r.text)) 9 except: 10 print("爬取失败")
输出:
https://www.so.com/s?q=Python
256963