views:

32

answers:

1

Hello, I'm working on a small project and I've run into a small problem. The script I have needs to fetch a website and find a specific value in the source HTML file. The value is like this:

id='elementID'> 

 <fieldset> 
  <input type='hidden' name='hash' value='e46c945fe32a3' /> 
 </fieldset> 

Now I'm been trying to use the ElementTree library to parse the HTML document to find the value but I haven't been very successful. I'm really new to Python so I don't really know what to do next.

I've been using httplib and urllib/urllib2 to connect to the website and POST my login details and things like that but I really don't know how to get that value from the page. I thought I could send a request for the input named 'hash' but I have no idea how to do that.

+2  A: 

You might consider looking at the BeautifulSoup library - it's designed to be quick and easy to use.

Amber
Thanks, that's probably exactly what I need but I'm not sure how to actually put it to use. Could you give me some hints on how to actually USE BeautifulSoup to search the HTML document?
Bjarki Jonasson
Take a look at the Quick Start portion of the documentation: http://www.crummy.com/software/BeautifulSoup/documentation.html#Quick Start
Amber