21,886
社区成员
发帖
与我相关
我的任务
分享
$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;
}