By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

log in to a website

P: n/a
I'm learning python, and my goal is to write a script that will log
into a website for me. The site uses HTTPS, the form uses the "POST"
method.
From what I've been able to find so far, it looks like i need to use

the urllib2 module...does anyone know where I can find some good sample
code to read up on how to do this?

-Thx

Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You may find the third-party modules "ClientForm" and "ClientCookie" to
be useful.

Using ClientForm, the following code uploads a file to a particular web form:
forms = ClientForm.ParseResponse(urllib2.urlopen(url))
f = forms[0]
f.add_file(open(local, "rb"), filename=remote, name="file")
u = f.click("attach")
urllib2.urlopen(u)

A web search should turn up the homepage for these modules.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCsdDgJd01MZaTXX0RAn3kAKCLB2/JuT7rdbJ7ZpfYGgNp/uFhmACfZAYx
zJ63Lz+w4ecz539Tcw7StuU=
=UE89
-----END PGP SIGNATURE-----

Jul 19 '05 #2

P: n/a


pa****************@hotmail.com wrote:
I'm learning python, and my goal is to write a script that will log
into a website for me. The site uses HTTPS, the form uses the "POST"
method.
From what I've been able to find so far, it looks like i need to use

the urllib2 module...does anyone know where I can find some good sample
code to read up on how to do this?

-Thx


Is it just BASIC authentication ? (http error code 401).

Clientform is still worth investigating - but if you want help on BASIC
authentication then checkout
http://www.voidspace.org.uk/python/a...tication.shtml

Best Regards,

Fuzzyman
http://www.voidspace.org.uk/python

Jul 19 '05 #3

P: n/a
Works like a gem! Thanks a ton. ClientForm and ClientCookie are great!

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.