Modified searchTwitter() -> search(), searchTwitterGen() -> searchGen() in twython3k
This commit is contained in:
parent
1d8f2a8851
commit
1d737b67d9
1 changed files with 308 additions and 294 deletions
|
|
@ -252,15 +252,20 @@ class Twython(object):
|
|||
except HTTPError as e:
|
||||
raise TwythonError("getSearchTimeline() failed with a %s error code." % repr(e.code), e.code)
|
||||
|
||||
def searchTwitterGen(self, search_query, **kwargs):
|
||||
"""searchTwitterGen(search_query, **kwargs)
|
||||
def searchTwitter(self, **kwargs):
|
||||
"""use search(search_query, **kwargs)
|
||||
searchTwitter("python", page = "2")"""
|
||||
return search(self, **kwargs)
|
||||
|
||||
def searchGen(self, search_query, **kwargs):
|
||||
"""searchGen(search_query, **kwargs)
|
||||
|
||||
Returns a generator of tweets that match a specified query.
|
||||
|
||||
Parameters:
|
||||
See the documentation at http://dev.twitter.com/doc/get/search. Pass in the API supported arguments as named parameters.
|
||||
|
||||
e.g x.searchTwitter(q="jjndf", page="2")
|
||||
e.g x.search(search_query="python", page="2")
|
||||
"""
|
||||
searchURL = Twython.constructApiURL("http://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
|
||||
try:
|
||||
|
|
@ -276,11 +281,20 @@ class Twython(object):
|
|||
yield tweet
|
||||
|
||||
if 'page' not in kwargs:
|
||||
kwargs['page'] = 2
|
||||
kwargs['page'] = '2'
|
||||
else:
|
||||
try:
|
||||
kwargs['page'] = int(kwargs['page'])
|
||||
kwargs['page'] += 1
|
||||
kwargs['page'] = str(kwargs['page'])
|
||||
except TypeError:
|
||||
raise TwythonError("searchGen() exited because page takes str")
|
||||
|
||||
for tweet in self.searchTwitterGen(search_query, **kwargs):
|
||||
except e:
|
||||
raise TwythonError("searchGen() failed with %s error code" %\
|
||||
repr(e.code), e.code)
|
||||
|
||||
for tweet in self.searchGen(search_query, **kwargs):
|
||||
yield tweet
|
||||
|
||||
def isListMember(self, list_id, id, username, version = 1):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue