SGMLlib module

H

Harlin Seritt

I am trying to use SGMLlib module to extract all links from some data I
pulled from the web (via urllib). I have looked at the documentation
online and can not make sense of it. As a quick example, how would I
get the hyperlinks for an html file?

thanks,

Harlin
 
P

Peter Hansen

Harlin said:
I am trying to use SGMLlib module to extract all links from some data I
pulled from the web (via urllib). I have looked at the documentation
online and can not make sense of it. As a quick example, how would I
get the hyperlinks for an html file?

I know you're not someone to ignore Google, but this looked like a
question that could pretty easily be answered using a quick search of
the comp.lang.python archives via Google Groups -- and it appears I was
right.

I tried
http://groups.google.ca/groups?q=sgmllib+extract+links+group:comp.lang.python.*
and found this page, which I believe should answer your question
(perhaps not directly, but it looks basically like an sgmllib tutorial):
http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html

I'm pretty sure you can find a dozen threads with snippets showing just
what you asked if you look at the result of the results.

-Peter
 
H

Harlin Seritt

Thanks for the help, I just didn't like the way that SGMLlib forces one
to instantiate a class to do this (or httplib for that matter). I
looked at those links you graciously sent (thanks!) but didn't like
them. At any rate, I went ahead and wrote my own. Thank goodness that
it's easy to parse with Python on your own!

Thanks for the help,

Harlin Seritt
 
J

John J. Lee

Peter Hansen said:
I know you're not someone to ignore Google, but this looked like a
question that could pretty easily be answered using a quick search of
the comp.lang.python archives via Google Groups -- and it appears I
was right.
[...]

Also, htmllib extends sgmllib to make this trivial, IIRC, so you
(Harlin) could look at the htmllib source.


John
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top