http://www.wangshanghai.com/SHP00001/frontend/product/info.jsp?id=100111033
想通过curl抓取上面的网页。但是不成功<?php  $ch = curl_init("http://www.wangshanghai.com/SHP00001/frontend/product/info.jsp?id=100115810"); ob_start(); 
curl_exec($ch); 
curl_close($ch); 
$str = ob_get_contents(); 
ob_end_clean(); 
echo $str;
?>以上是程序请问如何才能抓取到该页面啊

解决方案 »

  1.   

    $curl = curl_init(); // 设置你需要抓取的URL
    curl_setopt($curl, CURLOPT_URL, 'http://www.wangshanghai.com/SHP00001/frontend/product/info.jsp?id=100115810');// 设置header
    curl_setopt($curl, CURLOPT_HEADER, 1);// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);// 运行cURL,请求网页
    $data = curl_exec($curl);// 关闭URL请求
    curl_close($curl);// 显示获得的数据
    var_dump($data);