- 论坛徽章:
- 0
|
##getHtml.pl
use LWP::UserAgent;
use HTTP::Request::Common;
my $url = "http://192.168.1.1/" ;
my @html_page = getHTMLpage($url) ;
if(@html_page[0] =~/200 OK/) {
print "connect [" . $url . "] OK!\n";
print "get html :\n-----------------------\n";
@arg = split "\n", @html_page[0];
undef @html_page;
foreach (@arg){
push @check,"$_\n";
}
foreach (@check){
s/[\r\n]//g;
$html_line = $_;
$html_line2 = $html_line;
print $html_line . "\n";
}
}else{
#connect err
print "connect [" . $url . "] err!\n";
foreach ( @html_page ) {
print "$_\n";
}
exit(1);
}
exit(0);
## sub
sub getHTMLpage {
my $url = shift;
my $uagent = LWP::UserAgent->new;
$uagent->cookie_jar({});
$uagent->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windws NT 5.1)');
my $request= HTTP::Request->new(GET=>$url);
$request->content_type('applicationn/x-www-form-urlencoded');
$request->content();
my $res = $uagent->request($request);
return $res->as_string();
}
[ 本帖最后由 kiss2003 于 2006-2-10 16:39 编辑 ] |
|