當前位置:開發者網絡 >> 技術教程 >> CGI教程 >> CGI文檔 >> 內容
精彩推薦
分類最新教程
分類熱點教程
    
一個程序自動刷新頁面的例子(例如搜新浪小人)
作者:未知
日期:2003-09-13
人氣:
投稿:Andy.m(轉貼)
來源:未知
字體:
收藏:加入瀏覽器收藏
以下正文:
#!/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";
  }
相關文章: