Board logo

标题: 一个程序自动刷新页面的例子 [打印本页]

作者: cnangel    时间: 2005-8-25 19:54     标题: 一个程序自动刷新页面的例子

作者:小歪歪
日期:2001-1-12 15:49:23
  1. #!/usr/bin/perl
  2.   use HTTP::Request;
  3.   use LWP::UserAgent;
  4.   my $ua = new LWP::UserAgent;
  5.   $|=1;
  6.   print "content-type:text/html\n\n";
  7.   $ua->agent("AgentName/1.0 " . $ua->agent);
  8.   $ua->timeout(80);
  9.   # Create a request
  10.   my $req = new HTTP::Request POST => ';http://search.sina.com.cn/cgi-bin/search/search.cgi';;
  11.   $req->content_type(';application/x-www-form-urlencoded';);
  12.   my $buffer="ss=sina&_searchkey=%BB%EE%B6%AF%2B%BD%B1%CF%EE&_andor=and&s1=%CB%D1%CB%F7";
  13.   $req->content($buffer);
  14.   # Pass request to the user agent and get a response back
  15.   my $res = $ua->request($req);
  16.   # Check the outcome of the response
  17.   if ($res->is_success) {
  18. print length($res->content);
  19.    print <<END;
  20. <META HTTP-EQUIV="Refresh" Content=1;Host="http://***.***.***.***/nperl/autorefresh.pl">
  21. END
  22. ;
  23. print &#36;res->content ;
  24.   
  25.   } else {
  26. print "bad luck";
  27.   }
复制代码
——————以下内容由Cnangel2005年08月25日 07:59pm时添加———————

    不怎么高明,Perl是写socket的高手,为什么不用呢?




欢迎光临 星星博客 (http://commerce.huhoo.net/) Powered by Discuz! 7.0.0