Skip to content

Commit

Permalink
API.search() now includes search meta data as attributes of the Resul…
Browse files Browse the repository at this point in the history
…tSet object returned.

Example:
    results = api.search('python')
    print 'Search took %s seconds' % results.completed_in

This fixes issue #10 (http://github.com/joshthecoder/tweepy/issues/#issue/10)

Meta data available as of today:
    max_id, since_id, refresh_url, next_page, results_per_page,
    page, completed_in, query
  • Loading branch information
joshthecoder committed Jan 29, 2010
1 parent 9265984 commit 68c0f82
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tweepy/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ def parse_search_result(obj, api):

def parse_search_results(obj, api):

results = obj['results']
result_objects = ResultSet()
for item in results:
result_objects.append(parse_search_result(item, api))
return result_objects
results = ResultSet()
results.max_id = obj.get('max_id')
results.since_id = obj.get('since_id')
results.refresh_url = obj.get('refresh_url')
results.next_page = obj.get('next_page')
results.results_per_page = obj.get('results_per_page')
results.page = obj.get('page')
results.completed_in = obj.get('completed_in')
results.query = obj.get('query')

for item in obj['results']:
results.append(parse_search_result(item, api))
return results


def parse_list(obj, api):
Expand Down

0 comments on commit 68c0f82

Please sign in to comment.