1

这是python中的代码,不起作用且动机未知。

import json, urllib2
url = 'http://twitter.com/#!/search/PAROusuariosSUBTE'
server = urllib2.urlopen(url)
js = json.load(server)
res = js['results']
for espDeRes in res:
        espDeRes['from_user']
        espDeRes['text']

这是控制台中的错误。

Traceback (most recent call last):
  File "pro.py", line 4, in <module>
    js = json.load(server) 
  File "/usr/lib/python2.6/json/__init__.py", line 267, in load
    parse_constant=parse_constant, **kw)
  File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

任何的想法?

谢谢。

4

1 回答 1

2

我想,你的网址应该是http://search.twitter.com/search.json?q=PAROusuariosSUBTE,它应该工作?

于 2012-08-10T05:20:52.080 回答