使用curl抓取一个网页出现瓶颈 跳转打开模拟浏览器参数加上所有的参数都要提交清楚如果目标页面有对提交的IP做判断,那就直接死心吧. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个我已经写出来了,我是要的后面那个。。点击详细信息之后的 还没成功,难道真的限制了ip $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;} 求助php的多层if问题 (如何精简) 请问这种参数如何用PHP获得? 新手求教文件上传问题 正则表达式拆分字符串 求助:php 处理 bmp 缩微图 这个验证有必要么? JavaScript的提示如何换行? 求助:WINXP+IIS+PHP+MYSQL+PHPMYADMIN+Zend Optimizer的完整安装配置调试文档! ipb论坛密码验证的问题 正则求救:怎样去掉这个正则里面的允许中文中包含的全角空格? PHP的实例化对象的成员变量问题 求助PHP高手,日期显示格式问题
$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;
}