一个小程序[Socrates]中学到的Perl点滴

  

1. 抓取网页源文件,只要三行代码

use LWP::Simple;

$url='http://music.baidu.com/top/dayhot';

$page=get($url) or die "couldn't get $usr\n";

2. 搜索引擎URL的反编译

my ($url) = "http://www.baidu.com/s?wd=%E4%B8%AD%E5%9B%BD%E9%93%B6%E8%A1%8C&rsv_bp=0"; 

#编码

# $url =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg; 

# print "$url"; 



#解码

$url =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; 

print "$url"; 

 

 

 

 

 

你可能感兴趣的:(perl)