コード例 #1
0
function getInfo($url)
{
    $u = parse_url($url);
    $param = convertUrlQuery($u['query']);
    if (!stripos('taobao.com', $u['host'])) {
        //$shopUrl = "http://a.m.taobao.com/i".$param['id'].".htm";
        $shopUrl = "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $param['id'];
    } else {
        //$shopUrl = "http://a.m.tmall.com/i".$param['id'].".htm";
        $shopUrl = "http://detail.m.tmall.com/item.htm?id=" . $param['id'];
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $shopUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
    $file_contents = curl_exec($ch);
    //echo $file_contents;die;
    //echo curl_error($ch);
    //echo curl_getinfo($ch,CURLINFO_HTTP_CODE);
    curl_close($ch);
    if (!$file_contents) {
        $file_contents = file_get_contents($shopUrl);
    }
    if (stripos('taobao.com', $u['host']) === false) {
        $data = getTaobaoShopInfo($file_contents);
    } else {
        $data = getTmallShopInfo($file_contents);
    }
    $data['num_iid'] = $param['id'];
    return $data;
}
コード例 #2
0
ファイル: itemsAction.class.php プロジェクト: leamiko/58bitao
function getInfo($url)
{
    $u = parse_url($url);
    //解析get参数
    $param = convertUrlQuery($u['query']);
    $test['param'] = $param;
    //var_dump($param);exit;
    if (!stripos('taobao.com', $u['host'])) {
        $shopUrl = "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $param['id'];
    } else {
        $shopUrl = "http://detail.m.tmall.com/item.htm?id=" . $param['id'];
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $shopUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
    $file_contents = curl_exec($ch);
    curl_close($ch);
    if (!$file_contents) {
        $file_contents = file_get_contents($shopUrl);
    }
    if (!stripos('taobao.com', $u['host'] === false)) {
        $data = getTaobaoShopInfo($file_contents);
    } else {
        $data = getTmallShopInfo($file_contents);
    }
    $data['num_iid'] = $param['id'];
    return $data;
}
コード例 #3
0
function getInfo($url)
{
    $u = parse_url($url);
    //解析get参数
    $param = convertUrlQuery($u['query']);
    //var_dump($param);exit;
    if (!stripos('taobao.com', $u['host'])) {
        $shopUrl = "http://a.m.taobao.com/i" . $param['id'] . ".htm";
    } else {
        $shopUrl = "http://a.m.tmall.com/i" . $param['id'] . ".htm";
    }
    //echo $shopUrl;exit;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $shopUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
    $file_contents = curl_exec($ch);
    //echo $file_contents;die;
    //echo curl_error($ch);
    //echo curl_getinfo($ch,CURLINFO_HTTP_CODE);
    curl_close($ch);
    if (stripos('taobao.com', $u['host'] === false)) {
        $data = getTaobaoShopInfo($file_contents);
    } else {
        $data = getTmallShopInfo($file_contents);
    }
    $data['num_iid'] = $param['id'];
    return $data;
}