How to exctract title of links
Larry Bates
lbates at syscononline.com
Tue Apr 26 09:42:17 EDT 2005
You should take a look at BeautifulSoup at:
http://www.python.org/pypi/BeautifulSoup/2.0.2
Larry Bates
raver2046 wrote:
> here i have a link <a href="http://raver2046.ath.cx/CV/">cv network
> admin</a>
>
> how to extract "cv network admin"
>
>
> here is the code i have find to exctract link but not title of link
>
> ----------------------------
> import htmllib, formatter, urllib
> class x(htmllib.HTMLParser):
> def dump(self, tag, attrs):
> #print tag,
> for a, v in attrs:
> if a in ['a', 'src', 'href']:
> print v,
>
> print
> #def do_img(self, attrs):
> # self.dump('img', attrs)
> def start_a(self, attrs):
> self.dump('a', attrs)
> #def start_form(self, attrs):
> # self.dump('form', attrs)
>
> y = x(formatter.NullFormatter())
> y.feed(urllib.urlopen('http://www.aquabase.org/fish/dump.php3').read())
> y.close()
>
>
> ----------------------------
>
> http://raver2046.ath.cx/CV/cv_fr.html
>
>
More information about the Python-list
mailing list