#!/usr/bin/perl-w
# program code is simply a simple explanation of the use of parsing web content and matching patterns, the logic is not very strict
Use UTF8;
Binmode (STDIN, ': Encoding (UTF8) ');
Binmode (STDOUT, ': Encoding (UTF8) ');
Binmode (STDERR, ': Encoding (UTF8) ');
Use lwp::useragent;
Use Encode;
Sub get_data{
if (@_! = 1)
{
Print "error, need an argument\n";
return-1;
}
My $user _agent = lwp::useragent->new;
My $des = "http://tool.chinaz.com/Same/";
my $url _ip = $_[0];
My $response = $user _agent->post ($des, [' s ' = = $url _ip]);
if ($response->is_success) {
My $doc = Decode ("UTF8", $response->content);
while ($doc =~ m!<div id= "contenthtml" >\r\n ([^\r\n]*) </DIV>!SG) {
My $tmp = $;
$tmp =~ s!<ul> (. *) </ul>!$1!g;
$tmp = $;
while ($tmp =~ s!<li><span>[^<>]*</span>\s<a\s ([^<>]*) >[^<>]*</a> </li>!$1!) {
My $str = $;
$str =~ s! ' ([^ ']* ') '!$1!g;
print "$STR \ n";
}
}
}
}
&get_data ("61.135.169.125");
Exit