html parser etc help
Xah Lee
xah at xahlee.org
Tue Jun 11 18:45:43 EDT 2002
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.
* sample snipet that parse a given html file and print out all <a href> links.
* a sample snipet that fetch and print out the content of a given url.
Thanks. I've more or less read the python tutorial.
Xah
xah at xahlee.org
http://xahlee.org/PageTwo_dir/more.html
perl sample code to show what i mean.
# perl samples
# traverse dir and print out files ending in .html
use File::Find;
find(\&wanted, '/home/xah');
sub wanted {if($_ =~ m/\.html&/){print "$File::Find::name\n";}}
--
# fetch a given webpage
use LWP::Simple;
$content = get('http://xahlee.org/');
print $content;
--
# i'm too sick of reading HTML::Parser
# to understand how it's used.
More information about the Python-list
mailing list