开发者

post to page to login using beautiful soup

开发者 https://www.devze.com 2023-01-09 04:15 出处:网络
I\'m using python and beautifulsoup (new to both!), and I want to login to a suppliers website. So their form looks like (simplified):

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"开发者_JAVA技巧>

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

</form>

Is there a way to keep track for cookies?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消