使用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环境搭建问题 超级简单 高手帮忙啊!!! 求教,多级分类中类别深度问题 怎样让文章的每段前面留两个中文全角的空格?(贴代码) 关于mssql和php编码的问题。 小问题。 如何使某一页面只由另一页面链接而来时才有效?否则提示应该从哪个url进入 求新闻发布系统 邮件发送问题! 如何将utf-8编码的字符串转换为ASC11编码的字符串? 为什么我机子上的$PHP_SELF变量没有起作用? 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;
}