在 Python 中使用 HTTP 请求我能够得到响应,但是 json 和 simplejson 模块都无法解包它。两者都声称输入不是好的 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