Python,學霸
大家好!今天給你們帶來了透過requests爬取騰訊新聞提示詞簡單例項,僅供學習!
安裝:
pip install requests
例項:
import requests
url = "https://i.news.qq.com/searchSug"
payload = {
'query': 'python',
'devid': '00_00'
}
response = requests.post(url, data=payload)
print(response.text)#輸出
輸出:
{"ret":0,"queryList":["python","python菜鳥教程","python中的%用法","python編程入門自學","python什麽東西","python123","python編程","python下載","python手機版","python基礎知識"],"list":[{"title":"python"},{"title":"python菜鳥教程"},{"title":"python中的%用法"},{"title":"python編程入門自學"},{"title":"python什麽東西"},{"title":"python123"},{"title":"python編程"},{"title":"python下載"},{"title":"python手機版"},{"title":"python基礎知識"}]}