热门关键字:  ubuntu  分区  函数  Fedora  linux系统进程

当前位置 :| 主页>Linux教程>编程开发>Perl>

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

来源: 作者: 时间:2007-07-10 Tag: 点击:
#!/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";
}

最新评论共有 4 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
栏目列表