[perl] HTML 다루기

spring·2020년 11월 9일
0

1. Get HTML from URL.

use LWP::Simple;
my $html = get("https://root.cern.ch/download/cling/");

2. Get "href" in "a" tag from HTML.

use HTML::LinkExtractor;
use LWP::Simple;
my $html = get("https://root.cern.ch/download/cling/");
my $LX = new HTML::LinkExtractor();
$LX->parse(\$html);
for my $Link( @{ $LX->links } ) {
    print $$Link{href},"\n";
}
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( $url );
my @links = $mech->links();
for my $link ( @links ) {
   print $link->url,"\n";
}
profile
Researcher & Developer @ NAVER Corp | Designer @ HONGIK Univ.

0개의 댓글