views:

31

answers:

2

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?

+2  A: 

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.

S.Lott
ah ok, so urllib will store cookies also?
Blankman
http://www.nomadjourney.com/2009/03/automatic-site-login-using-python-urllib2/Has a nice example of what you are trying to do.
GWW
@Blankman: Keep reading. Yes. urllib2 handles cookies.
S.Lott
+2  A: 

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

Alex Martelli