Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

post to page to login using beautiful soup

I'm using python and beautifulsoup (new to both!), and I want to login to a suppliers website.

So their form looks like (simplified):

<form name=loginform action=/index.html method="post">

<input name=user>
<input name=pass">

</form>

Is there a way to keep track for cookies?

like image 895
Blankman Avatar asked Jul 27 '10 01:07

Blankman


2 Answers

Do some more reading.

Read about urllib2 That's what you use to do a POST to login. If you know the <input> names, you don't need Beautiful Soup. http://docs.python.org/library/urllib2.html

Beautiful Soup is what you use to parse a page of results. After you login. After you post the real request.

like image 178
S.Lott Avatar answered Sep 28 '22 06:09

S.Lott


Use mechanize -- that's just the best (3rd party) Python library for interacting with web forms, keeping track of cookies &c.

like image 43
Alex Martelli Avatar answered Sep 28 '22 08:09

Alex Martelli