This one scrapes the information from UMN Lookup

Try it out for yourself at utilitymill.

import BeautifulSoup
import urllib

def html2text(node):
    if not hasattr(node, 'contents'):
        return node.replace('n', ' ')
    if node.isSelfClosing:
        return ' '
    return ''.join([html2text(x) for x in node.contents])

def lookup(username):
    html = urllib.urlopen("" + username).read()
    soup = BeautifulSoup.BeautifulSoup(html)
    data = {}
    for heading in soup('th'):
        key = heading.contents[0][:-1]
        val = html2text(heading.findNext())
        data[key] = val
    return data

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s