淘宝抓取信息接口


header("Content-type: text/html; charset=utf-8"); 
 function get_item_taobao($itemid = '', $taobaourl = '', $pcate = 0, $ccate = 0, $tcate = 0, $merchid = 0) 
    {
        $url =get_taobao_info_url($itemid);
        //print($url);
        //load()->func('communication');
        $response = ihttp_get($url);
        print_r($response['data']);
        print_r($response['data']['itemInfoModel']['title']);

    }

function ihttp_get($url){
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
$data = curl_exec($ch);//运行curl
curl_close($ch);
return json_decode($data, true);
}


function get_taobao_info_url($itemid) 
    {
        return 'http://hws.m.taobao.com/cache/wdetail/5.0/?id=' . $itemid;
    }
function get_taobao_detail_url($itemid) 
    {
        return 'http://hws.m.taobao.com/cache/wdesc/5.0/?id=' . $itemid;
    }
$itemid='542238227242';
get_item_taobao($itemid);

?>

你可能感兴趣的:(抓取淘宝,淘宝接口)