一个程序自动刷新页面的例子

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

#!/usr/bin/perl

use HTTP::Request;

use LWP::UserAgent;

my $ua = new LWP::UserAgent;

$|=1;

print "content-type:text/html\n\n";

$ua->agent("AgentName/1.0 " . $ua->agent);

$ua->timeout(80);

# Create a request

my $req = new HTTP::Request POST => 'http://search.sina.com.cn/cgi-bin/search/search.cgi';

$req->content_type('application/x-www-form-urlencoded');

my $buffer="ss=sina&_searchkey=%BB%EE%B6%AF%2B%BD%B1%CF%EE&_andor=and&s1=%CB%D1%CB%F7";

$req->content($buffer);

# Pass request to the user agent and get a response back

my $res = $ua->request($req);

# Check the outcome of the response

if ($res->is_success) {

print length($res->content);

print <<END;

<META HTTP-EQUIV="Refresh" Content=1;Host="http://***.***.***.***/nperl/autorefresh.pl">

END

;

print $res->content ;

} else {

print "bad luck";

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航