newbie question

J

John

I'm working with the HTMLParser module and have implemented
HTMLParser.handle_starttag() and I see there is a separate
handle_data
method (which can be implemented), but I am not clear how to tie this
together with a given start tag, so I only get the data I want.

For example, I'd like to get a handle on the character data ( the
number 1) immediately after the following start tag


<span class="calPast">
1</br>
..
..
..
Any ideas?
 
G

Gabriel Genellina

I'm working with the HTMLParser module and have implemented
HTMLParser.handle_starttag() and I see there is a separate
handle_data
method (which can be implemented), but I am not clear how to tie this
together with a given start tag, so I only get the data I want.

For example, I'd like to get a handle on the character data ( the
number 1) immediately after the following start tag


<span class="calPast">
1</br>
.
.
.
Any ideas?

I usually don't recommend HTMLParser because a lot of HTML documents in
the Web are not even remotely valid, and the parser can't handle that.
BeautifulSoup is a more robust alternative:
<http://www.crummy.com/software/BeautifulSoup/>
 

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,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top