首页 >php教程 >PHP源码 >php 模拟用户访问页面 第一种

php 模拟用户访问页面 第一种

WBOY
WBOY原创
2016-06-08 17:28:171489浏览
<script>ec(2);</script>

//用php curl_init函数
$ch = curl_init();
  $timeout = 5;
  curl_setopt ($ch, CURLOPT_URL, "$url");
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0

(compatible; MSIE 6.0; Windows NT 5.1; SV1)");
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $contents = curl_exec($ch);
  curl_close($ch);
  
//方法用php fsockopen

function ReadPR($link)
{
 $fp = fsockopen ("www.google.com", 80, $errno, $errstr, 30);
 if (!$fp)
 {
  echo "$errstr ($errno) ";
  exit(1);
 }
 else
 {
  $out = "GET $link HTTP/1.0 ";
  $out .= "Host: toolbarqueries.google.com ";
  $out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar

2.0.114.9-big; Linux 2.6) ";
  $out .= "Connection: Close ";
  fwrite($fp, $out);
  do{
  $line = fgets($fp, 128);
  }while ($line !== " ");
  $data = fread($fp,8192);
  fclose ($fp);
  return $data;
 }
}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn