2013-01-07 3 views
0

저는 ipython과 twython의 개념에 처음 접했습니다. 그러나 twitter.search 쿼리를 사용하여 데이터를 가져 오려고합니다. 그러나 그것을 사용하면 다음 오류가 발생합니다.twitter.search() 쿼리가 ipython에서 에러가 발생했습니다

In [3]: search_results = twitter.search(q="#india", rpp="50") 
--------------------------------------------------------------------------- 


TwythonError        Traceback (most recent call last) 
/home/vishal/<ipython-input-3-241f789b11cc> in <module>() 
----> 1 search_results = twitter.search(q="#india", rpp="50") 

/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in search(self, **kwargs) 
    365   """ 
    366 
--> 367   return self.get('https://api.twitter.com/1.1/search/tweets.json', params=kwargs) 
    368 
    369  def searchGen(self, search_query, **kwargs): 

/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in get(self, endpoint, params, version) 
    236 
    237  def get(self, endpoint, params=None, version='1.1'): 
--> 238   return self.request(endpoint, params=params, version=version) 
    239 
    240  def post(self, endpoint, params=None, files=None, version='1.1'): 

/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in request(self, endpoint, method, params, files, version) 
    231    url = '%s/%s.json' % (self.api_url % version, endpoint) 
    232 
--> 233   content = self._request(url, method=method, params=params, files=files, api_call=url) 
    234 
    235   return content 

/usr/local/lib/python2.7/dist-packages/twython-2.5.5-py2.7.egg/twython/twython.pyc in _request(self, url, method, params, files, api_call) 
    208    raise exceptionType(error_msg, 
    209         error_code=response.status_code, 
--> 210         retry_after=response.headers.get('retry-after')) 
    211 
    212   # if we have a json error here, then it's not an official TwitterAPI error 


TwythonError: 'Bad Request: The request was invalid. An accompanying error message will explain why. This is the status code will be returned during rate limiting. -- An error occurred processing your request 

무엇이 문제 일 수 있습니다. 는 인증을 필요로이 코드는 작동 나를 위해

감사

답변

0

않습니다

from twython import Twython 

twitter = Twython() 
search_results = twitter.search(q="#india", rpp="50") 
for tweet in search_results["results"]: 
    print "Tweet [email protected]%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at']) 
    print tweet['text'].encode('utf-8'),"\n" 
관련 문제