Re: [Tutor] Parsing html user HTMLParser

2006-04-20 Thread Danny Yoo


> I need help here, I'm struggling with html parsing method, up until now 
> I can only put and html file as instance. I have no experience with 
> this, I want to read the childs inside this document and modify the 
> data. What can I do if I start from here?

Hi Titvirak,

You might want to take a look at a different module for parsing HTML.  A 
popular one is BeautifulSoup:

 http://www.crummy.com/software/BeautifulSoup/

Their quick-start page shows how to do simple stuff.  There are a few 
oddities with BeautifulSoup, but on the whole, it's pretty good.

Good luck to you!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Parsing html user HTMLParser

2006-04-20 Thread Kent Johnson
ទិត្យវិរៈ wrote:
> Hi folks,
> 
> I need help here, I'm struggling with html parsing method, up until now
> I can only put and html file as instance. I have no experience with
> this, I want to read the childs inside this document and modify the
> data. What can I do if I start from here?
> 
>> from HTMLParser import HTMLParser
>>
>> p = HTMLParser()
>> s = open('/home/virak/Documents/peace/test.html').read()
>> p.feed(s)
>>
>> print p
>>
>> p.close()

Here is an example that might be useful, though the usage is not too 
clear...
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286269

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Parsing html user HTMLParser

2006-04-20 Thread ទិត្យវិរៈ
Hi folks,

I need help here, I'm struggling with html parsing method, up until now
I can only put and html file as instance. I have no experience with
this, I want to read the childs inside this document and modify the
data. What can I do if I start from here?

> from HTMLParser import HTMLParser
>
> p = HTMLParser()
> s = open('/home/virak/Documents/peace/test.html').read()
> p.feed(s)
>
> print p
>
> p.close()
Titvirak
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor