2015-04-22 54 views
0

我是新來的蟒蛇,和我目前重複從書「蟒蛇數據分析」沒有JSON對象可以被解碼爲Web API的

全部解決的例子舉一個例子,我需要訪問來自twitter搜索的API。這裏是代碼:

import requests 
url='https://twitter.com/search?q=python%20pandas&src=typd' 
resp=requests.get(url) 

一切工作正常到這裏。問題是當我使用json

import json 
data=json.loads(resp.text) 

然後我收到錯誤消息ValueError: No JSON object could be decoded

我試圖切換到另一個網址,而不是Twitter的,但我仍然收到同樣的錯誤消息。

有沒有人有一些想法?謝謝

+3

這是因爲響應不是JSON,而是HTML – Carlangueitor

+0

'print(resp.text)'給出了什麼......? – deceze

+0

使用API​​獲取JSON格式[例如](https://dev.twitter.com/rest/reference/get/search/tweets) –

回答

相關問題