This one logs me into

import urllib
import cookielib

class dummy_request:
    def get_full_url(self):
        return '/'

def extract_cookies(response):
    """Given a response, returns a dictionary of the cookies."""
    ns_headers = response.headers.getheaders("Set-Cookie")
    attrs_set = cookielib.parse_ns_headers(ns_headers)
    cookie_tuples = cookielib.CookieJar()._normalized_cookie_tuples(attrs_set)
    cookies = {}
    for tup in cookie_tuples:
        name, value, standard, rest = tup
        cookies[name] = value
    return cookies
def log_into_pop(username, password):
    url = ''
    args = {'edit[name]': username, 'edit[pass]': password}
    response = urllib.urlopen(url, urllib.urlencode(args))
    return extract_cookies(response)

if __name__ == '__main__':
    import getpass
    username = 'Collin Anderson'
    password = getpass.getpass()
    print log_into_pop(username, password)

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s