在Python中使用HTTP請求我能夠得到響應,但無論是json還是simplejson模塊都無法解壓縮它。兩者都聲稱輸入不是很好的json。谷歌趨勢API讀取到python時不好json
import requests
import json
html_base = u"http://www.google.com/trends/fetchComponent?q="
q = u"asdf,qwerty"
query_type = u"&cid=TIMESERIES_GRAPH_0&export=3"
full_query = html_base + q + query_type
response = requests.get(full_query)
data = json.loads(response.text)
錯誤:
C:\Anaconda\lib\json\decoder.pyc in raw_decode(self, s, idx)
382 obj, end = self.scan_once(s, idx)
383 except StopIteration:
--> 384 raise ValueError("No JSON object could be decoded")
385 return obj, end
ValueError: No JSON object could be decoded
那麼,'response.text'裏有什麼?你想要解析什麼? – 2014-10-04 21:47:41