想抓移动官网的优惠列表,是js动态ajax提交获取的内容,在本地根据参数写个post表单可以正常提交获取到内容,根据修改页数的参数可以获取到不同页的内容,不是获取,内容显示的页面还是在移动官网提交的地址。 用curl模拟post的提交,那边就获取不到参数,不能根据页数获取到内容用curl提交到本地的接收测试页面,可以收到post数据。。这是为什么呢,是因为移动官网做了防抓取吗。。求大神帮忙看看。http://gd.10086.cn/peting/preferential/common/index/preferencelist.jsps(这是ajax请求地址)参数:
currPage:2(页数)
queryCityCodeId:SZ(各市的首拼音大写)
queryBrandCodeId:(空)
queryTypeId:(空)
queryRange:(空)
queryByAssigned:(空)
queryKeyWord:(空)phpcurl移动表单ajax
currPage:2(页数)
queryCityCodeId:SZ(各市的首拼音大写)
queryBrandCodeId:(空)
queryTypeId:(空)
queryRange:(空)
queryByAssigned:(空)
queryKeyWord:(空)phpcurl移动表单ajax
解决方案 »
- 如何截取字符串并以零补齐?
- 编码用gb2312(ANSI)还是utf-8 大家都来讨论下 自己在用哪种编码
- php下载文件的问题
- 请高手帮忙看下,怎么获取用户提交的值中,首个英文字母,并输出?谢谢
- 关于布署 PHPCMS后,用注册用户登录后,找不到网页(即自动跳转到登录后首页),请有遇到过此问题的大侠帮忙解决
- php soapclient问题请教
- 问题很明显,就是不知道怎么解决?
- 请辞HTML,PHP,其他版块的板主……
- 启动apache时,为什么提示“通常每个套接字(协议/地址/端口)地址只能使用一次。make_sock could not bind to address0.0.0.0:80 no lis
- 为什么图片只显示了半张?
- 这个谁会啊?求代码
- 求解答
function get_curlcuconent2($filename,$referer)
{
$cookie_jar = tempnam('./temp','JSESSIONID');
$header = array (
"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Cache-Control:no-cache",
"Content-Length:103",
"Content-Type:application/x-www-form-urlencoded",
"Host:gd.10086.cn",
"Origin:http://localhost",
"Referer:http://localhost/",
);
$post_data = array (
"currPage" => "5",
"queryCityCodeId" => "SZ",
"queryBrandCodeId" => "",
"queryTypeId" => "",
"queryRange" => "",
"queryByAssigned" => "",
"queryKeyWord" => ""
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $filename);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
$filecontent=curl_exec($ch);
curl_close($ch);
$ch = curl_init();
$hostname ="gd.10086.cn";
//$referer="http://www.domain.com/";
curl_setopt($ch, CURLOPT_URL, $filename);
// curl_setopt($ch, CURLOPT_REFERER, $referer);
// curl_setopt($ch, CURLOPT_USERAGENT, "gd.10086.cn"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$filecontent = curl_exec($ch);
// preg_match_all("/charset=(.+?)[NULL\"\']/is",$filecontent, $charsetarray);
// if(strtolower($charsetarray[1][0])=="utf-8")
// $filecontent=iconv( 'utf-8', 'gb18030//IGNORE' , $filecontent);
curl_close($ch);
return $filecontent;
}
这个是优惠列表页面:http://gd.10086.cn/peting/preferential/index.jsp