html parser etc help
Andy McKay
amckay at merlintechnologies.com
Tue Jun 11 19:27:09 EDT 2002
On 11/06/02 15:45 -0700, Xah Lee wrote:
> i'm learning python in hoping to do switch web programing from perl.
> can anyone show me code snipets for the following problem to get
> me started?
>
> * snipet to traverse a directory and list files by typer or suffix.
have a look at glob or listdir
import glob
glob.glob('*.py')
> * sample snipet that parse a given html file and print out all <a href> links.
a snippet that will read <link> tags
http://www.agmweb.ca/Scripts/rssAutoDiscovery
> * a sample snipet that fetch and print out the content of a given url.
as above
> --
> # fetch a given webpage
> use LWP::Simple;
> $content = get('http://xahlee.org/');
> print $content;
hey its even shorter in python :)
from urllib import urlopen
print urlopen('http://xahlee.org').read()
--
Andy McKay
Merlin Technologies
More information about the Python-list
mailing list