Returning more than one result

Posted by Hairr on Stack Overflow See other posts from Stack Overflow or by Hairr
Published on 2012-09-30T15:31:11Z Indexed on 2012/09/30 15:37 UTC
Read the original article Hit count: 243

Filed under:
|

I'm using the following code:

def recentchanges(bot=False,rclimit=20):
    """
    @description: Gets the last 20 pages edited on the recent changes and who the user who     edited it
    """
    recent_changes_data = {
        'action':'query',
        'list':'recentchanges',
        'rcprop':'user|title',
        'rclimit':rclimit,
        'format':'json'
    }
    if bot is False:
        recent_changes_data['rcshow'] = '!bot'
    else:
        pass
    data = urllib.urlencode(recent_changes_data)
    response = opener.open('http://runescape.wikia.com/api.php',data)
    content = json.load(response)
    pages = tuple(content['query']['recentchanges'])
    for title in pages:
        return title['title']

When I do recentchanges() I only get one result. If I print it though, all the pages are printed.
Am I just misunderstanding or is this something relating to python?

Also, opener is:

cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

© Stack Overflow or respective owner

Related posts about python

Related posts about wiki