求php,远程抓取代码,谢谢 190C

抓取网站http://www.131458.com
通过 POST查询提交到http://www.131458.com/handler/load.aspx/Load
传递参数nick=z224324
得到图2的结果,请问curl怎么抓取图二的结果呀?
图一:
图片说明
图二:
图片说明

2个回答

 $data="{'nick':'z224324'}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, 'http://www.131458.com/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36');
curl_setopt($ch, CURLOPT_URL, 'http://www.131458.com/handler/load.aspx/Load');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json;charset=utf-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$content = curl_exec($ch);

$d=json_decode($content);

echo $d->d;
 /**
 * @link http://www.aiit.wang
 *curl判断判断远程图片或文件是否存在
 */
function url_exists($url) {
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    //不下载
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    //设置超时
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 3);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if($http_code == 200) {
        return true;
    }
    return false;
}

参考文章:PHP判断远程图片或文件或url是否存在

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐