Пример #1
0
if ($c_id == 0) {
    //没有选择分类,则默认全部分类被选中
    $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "\" class=\"curcateitem\">\\<span class=\"curcateitemword\">全部</span></a>";
} else {
    $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "\" class=\"cateitem\"><span class=\"cateitemword\">全部</span></a>";
}
for ($i = 0; $i < count($categories); $i++) {
    if ($c_id == $i + 1) {
        //分类id对应则显示该分类被选中
        $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "&id=" . ($i + 1) . "\" class=\"curcateitem\"><span class=\"curcateitemword\">" . $categories[$i]['c_name'] . "</span></a>";
    } else {
        $categoryStr .= "<a href=\"./index.php?mall_id=" . $mall_id . "&id=" . ($i + 1) . "\" class=\"cateitem\"><span class=\"cateitemword\">" . $categories[$i]['c_name'] . "</span></a>";
    }
}
//查看所有商城信息
$mallSource = new MallSource();
$sources = $mallSource->getMallSource();
$mallStr = "";
if ($mall_id == 0) {
    //没有选择商城,则默认全部商城被选中
    $mallStr .= "<a href=\"./index.php?id=" . $c_id . "\" class=\"curcateitem\"><span class=\"curcateitemword\">全部</span></a>";
} else {
    $mallStr .= "<a href=\"./index.php?id=" . $c_id . "\" class=\"cateitem\"><span class=\"cateitemword\">全部</span></a>";
}
for ($i = 0; $i < count($sources); $i++) {
    if ($mall_id == $i + 1) {
        //商城id对应则显示该分类被选中
        $mallStr .= "<a href=\"./index.php?id=" . $c_id . "&mall_id=" . ($i + 1) . "\" class=\"curcateitem\"><span class=\"curcateitemword\">" . $sources[$i]['mallName'] . "</span></a>";
    } else {
        $mallStr .= "<a href=\"./index.php?id=" . $c_id . "&mall_id=" . ($i + 1) . "\" class=\"cateitem\"><span class=\"cateitemword\">" . $sources[$i]['mallName'] . "</span></a>";
    }
Пример #2
0
<?php

//加载初始化文件
include_once '../includes/init.php';
date_default_timezone_set('Asia/Shanghai');
$mallSources = new MallSource();
$mid = $mallSources->getMallId('天猫');
$category = new Category();
/**
 * 存储xml文件
 */
$source = tmall;
$filename = 'xml/' . date('YmdH', time()) . '-' . $source . '.xml';
echo $filename;
$productXml = simplexml_load_file($filename);
/**
 * 提取信息并入库
 */
$results = $productXml->results;
$items = $results->n_tbk_item;
foreach ($items as $item) {
    echo $item->title . '----' . $item->item_url . '<br/><br/>';
}
Пример #3
0
date_default_timezone_set('Asia/Shanghai');
$appkey = '23329942';
$secretKey = '96a5402b10955deea6c2d4a7d967f5e1';
$client = new TopClient();
$client->appkey = $appkey;
$client->secretKey = $secretKey;
$productCount = 1000;
//每一种类的商品需要获取的数据量
$pageCount = 10;
//需要存储记录的总页数
$pageSize = 100;
//每一页的记录数
/**
 * 获取商城id
 */
$mallSouce = new MallSource();
$isTMall = false;
$isTMallStr = 'true';
if ($isTMall) {
    $mallName = '天猫';
} else {
    $mallName = '淘宝';
    $isTMallStr = 'false';
}
$mall_id = $mallSouce->getMallId($mallName);
/**
 * 获取类型
 */
$cate = new Category();
$categories = $cate->getCategory();
$index = 1;