Python to PHP Login System (HTTP Post)
John J. Lee
jjlee at reportlab.com
Sat Jun 24 19:20:33 EDT 2006
jjlee at reportlab.com (John J. Lee) writes:
[...]
> #-------------------------------
> import mechanize
>
> SHOW_COOKIES = True
>
> br = mechanize.Browser()
> if SHOW_COOKIES:
> cj = mechanize.CookieJar()
> br.set_cookiejar(cj)
> br.open("http://www.magnetshare.com/main.php")
> br.select_form(nr=0)
> br["user"] = "joe"
> br["pass"] = "password"
> r = br.submit()
> assert "Logged In" in r.get_data()
> if SHOW_COOKIES:
> for cookie in cj:
> print cj
> #-------------------------------
That last line should of course have been:
print cookie
and not:
print cj
John
More information about the Python-list
mailing list