How do initial login/password before can download web file with urllib?

S

seberino

I finally figured out how to use the wonderful module urllib to
download files.

What if web page requires you to fill out a form with login and
password first?

Is this just like any other FORM? Can login/password from a GET method
form be handled by appending something like "?login=foo,password=bar"
to URL?

Is that right way?

Chris
 
P

Peter Hansen

I finally figured out how to use the wonderful module urllib to
download files.

What if web page requires you to fill out a form with login and
password first?

Is this just like any other FORM? Can login/password from a GET method
form be handled by appending something like "?login=foo,password=bar"
to URL?

Is that right way?

If by "the URL" you mean the one that was used to retrieve the page in
the first place, then the answer is "not necessarily, and rarely".
Generally you need to parse the FORM and use its "action" attribute as
the URL, plus whatever form fields are required. It might be just login
and password, but the choice of names is form-specific and there may be
other (even hidden) fields that are required. Tools such as
http://wwwsearch.sourceforge.net/mechanize/ can help you with this.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top