BeautifulSoup to get string inner 'p' and 'a' tags
GinTon
jonasmg at softhome.net
Mon Jul 24 05:43:18 EDT 2006
I'm trying to get the 'FOO' string but the problem is that inner 'P'
tag there is another tag, 'a'. So:
> from BeautifulSoup import BeautifulSoup
> s = '<td width="88%" valign="TOP"> <p class="contentBody">FOO <a name="f"></a> </p></td>'
> tree = BeautifulSoup(s)
> print tree.first('p')
<p class="contentBody">FOO <a name="f"></a> </p>
So if I run 'print tree.first('p').string' to get the 'FOO' string it
shows Null value because it's the 'a' tag:
> print tree.first('p').string
Null
Any solution?
More information about the Python-list
mailing list