in reply to Displaying the source code of a web page
A few options (your question wasn't specific enough as to narrow down what you're after):
perl -MLWP::Simple=getprint -e 'getprint("http://perlmonks.org");' >fi +lename_source.html
...or...
mojo get perlmonks.org >filename_source.html
...or...
perl -Mojo -E 'say g("perlmonks.org")->dom->html'
The first construct requires LWP::Simple, and the second and third, Mojolicious (which is probably only advisable if you have some other reason to have it on your system).
If you're on a Unix/Linux system you might already have curl installed.
If you want to incorporate it into a larger script:
use strict; use warnings; use LWP::Simple qw(get); my $raw_page = get( 'http://perlmonks.org' ); open my $html_ofh, '>', 'filename.txt' or die $!; print {$html_ofh} $raw_page; close $html_ofh or die $!;
Other notables include WWW::Mechanize, LWP::UserAgent, WWW::Mechanize::Firefox, ... and a whole bunch of HTML parsers and link extractors that you can find by visiting your favorite CPAN search tool.
Dave
|
|---|