跳转打开
模拟浏览器参数加上所有的参数都要提交清楚如果目标页面有对提交的IP做判断,那就直接死心吧.

解决方案 »

  1.   

    这个我已经写出来了,我是要的后面那个。。点击详细信息之后的
      

  2.   

    还没成功,难道真的限制了ip
      

  3.   

    $url = 'http://www.sgs.gov.cn/lz/etpsInfo.do?method=index';//$cookiejar = realpath('cookie.txt');
    $url = 'http://www.sgs.gov.cn/lz/etpsInfo.do?method=doSearch';
    $ar = array('searchType' =>1, 'keyWords' => iconv('gbk', 'utf-8', '上海科波'));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $ar);
    //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $t = curl_exec($ch);
    curl_close($ch);preg_match_all("/viewDetail\('(\d+)'\)/", $t, $r);
    foreach($r[1] as $id) {
      echo "$id\n";
      $url = 'http://www.sgs.gov.cn/lz/etpsInfo.do?method=viewDetail';
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,$url);
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch, CURLOPT_REFERER, "http://www.sgs.gov.cn/lz/");
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, "etpsId=$id");
    //  curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      $t = curl_exec($ch);
      curl_close($ch);
      echo $t;
    }