淘宝抓取信息接口

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35669659/article/details/75371194
<?php
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);

?>
展开阅读全文

没有更多推荐了,返回首页