#!/usr/bin/perl
# Include the WWW::Mechanize module
use WWW::Mechanize;
# What URL shall we retrieve?
$url = "http://www.example.com/bestselling.html";
# Create a new instance of WWW::Mechanize
my $mechanize = WWW::Mechanize->new(autocheck => 1);
# Retrieve the page
$mechanize->get($url);
# Retrieve the page title
my $title = $mechanize->title;
print "<b>$title</b><br />";
# Place all of the links in an array
my @links = $mechanize->links;
# Loop through and output each link
foreach my $link (@links) {
# Retrieve the link URL
my $href = $link->url;
# Retrieve the link text
my $name = $link->text;
print "<a href=\"$href\">$name</a>\n";
}
2006년 12월 6일 수요일
[WWW::Mechanize] $mechanize->links 예제
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기