public function click_url() { $iid = I('iid'); $url = I('click_url'); !$iid && exit('false'); $item = $this->_mod->where(array('num_iid' => $iid))->find(); if (!$item['click_url'] && !strpos($item['click_url'], "s.click") && !strpos($item['click_url'], "redirect.simba.taobao.com")) { $url = str_replace("[]", "&", $url); $url = $this->urlChange($url); $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $content = $ftxia_https->results; if (!$content) { $content = file_get_contents($url); } $forwardStr = $this->ChGetWord($content, 'class="big-img" href="', '"'); $click_url = $this->urlChange($forwardStr); $item['click_url'] = $click_url; if ($id) { $this->_mod->where(array("id" => $id))->save($item); } if ($iid) { $ids = $this->_mod->where(array("num_iid" => $iid))->save($item); if (!$ids) { $this->ajaxReturn(2, "直接跳转", 'url'); } } $this->ajaxReturn(1, "获取url成功", $forwardStr); } else { $this->ajaxReturn(1, "获取url成功", $item['click_url']); } }
protected function html($url) { $ftxia_https = new ftxia_https(); $ftxia_https->html($url); $content = $ftxia_https->results; if (!$content) { $content = $this->http($url); } return $content; }
public function collect() { $source = ''; if (false === ($setting = F('uz800_setting'))) { $this->ajaxReturn(0, L('illegal_parameters')); } $p = $this->_get('p', 'intval', 1); $url = 'http://zhe800.uz.taobao.com/list.php?&tag_id=' . $setting['cid'] . '&page=' . $p; if ($p == 1) { $totalcoll = 0; } else { $totalcoll = F('totalcoll'); } $coll = 0; $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $source = $ftxia_https->results; if (!$source) { $source = file_get_contents($url); } $source = rtrim(ltrim(trim($source), '('), ')'); $source = iconv('GBK', 'UTF-8//IGNORE', $source); if (strpos($source, '对不起! 本分类下暂时没有淘宝限时特价商品!')) { $this->ajaxReturn(0, '该类目暂时没有特价商品'); } if (preg_match_all('/<div class="deal(.*?)<\\/div>/s', $source, $matchitem)) { for ($i = 0; $i < count($matchitem[1]); $i++) { $item = $matchitem[1][$i]; $title = get_word($item, '<h2>', '<\\/h2>'); $title = preg_replace("@<strong(.*?)<\\/strong>@is", "", $title); $title = preg_replace("/<a[^>]+>/", "", $title); $title = preg_replace("/<\\/a>/", "", $title); $img = get_word($item, '<img src="', '_290x290.jpg"', '\\/>'); $url = get_word($item, '<p>', '<\\/p>'); $url = preg_replace("@<img(.*?)\\/>@is", "", $url); preg_match("/id=(\\d*)/", $url, $num); $iid = isset($num[1]) ? $num[1] : ''; $price = get_word($item, '<i>¥', '<\\/i>'); $zkprice = get_word($item, '<\\/b>', '<em><\\/em><\\/em>'); $intro = get_word($item, '<h6>', '<\\/h6>'); $intro = preg_replace("@<em(.*?)<\\/em>@is", "", $intro); $intro = trim($intro); if (stripos($url, 'taobao.com') > 0) { $shop_type = 'C'; } else { $shop_type = 'B'; } $likes = rand(99, 9999); $ems = '1'; $zkou = round($zkprice / $price * 10, 1); if (!defined(ENDTIME)) { define('ENDTIME', '72'); } if (!$times) { $times = (int) (time() + ENDTIME * 3600); } $itemUrl = "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $iid; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $itemUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); $contents = curl_exec($ch); curl_close($ch); if (!$contents) { $contents = file_get_contents($itemUrl); } $comslist = json_decode($contents, true); $info = array(); $tmp = json_decode($comslist['data']['apiStack'][0]['value'], true); $info['title'] = $comslist['data']['itemInfoModel']['title']; $info['volume'] = $tmp['data']['itemInfoModel']['totalSoldQuantity']; $info['pic_url'] = $comslist['data']['itemInfoModel']['picsPath'][0]; $info['pic_url'] = str_replace("_320x320.jpg", "", $info['pic_url']); $info['sellerId'] = $comslist['data']['seller']['userNumId']; $info['nick'] = $comslist['data']['seller']['nick']; $title = $info['title']; $nick = $info['nick']; $img = $info['pic_url']; $sellerId = $info['sellerId']; $volume = $info['volume']; $tag_list = d("items")->get_tags_by_title($title); $tags = implode(" ", $tag_list); $itemarray['shop_type'] = $shop_type; $itemarray['title'] = $title; $itemarray['tags'] = $tags; $itemarray['pic_url'] = $img; $itemarray['num_iid'] = $iid; $itemarray['price'] = $price; $itemarray['coupon_price'] = $zkprice; $itemarray['volume'] = $volume; $itemarray['nick'] = $nick; $itemarray['sellerId'] = $sellerId; $itemarray['intro'] = $intro; $itemarray['ems'] = $ems; $itemarray['likes'] = $likes; $itemarray['cate_id'] = $setting['cate_id']; $itemarray['coupon_rate'] = $zkou * 1000; $itemarray['coupon_end_time'] = $times; $itemarray['coupon_start_time'] = time(); if ($title && $img && $iid) { $result['item_list'][] = $itemarray; } } } // exit(print_r($result)); foreach ($result['item_list'] as $key => $val) { $res = $this->_ajax_tb_publish_insert($val); if ($res > 0) { $coll++; } $totalcoll++; } if (strpos($source, '<span class="page-next" title="下一页">')) { $this->ajaxReturn(0, '已经采集完成' . $p . '页,本次采集到' . $totalcoll . '件商品!请返回,谢谢'); } F('totalcoll', $totalcoll); $this->assign('p', $p); $this->assign('coll', $coll); $this->assign('totalnum', $totalnum); $this->assign('totalcoll', $totalcoll); $resp = $this->fetch('collect'); $this->ajaxReturn(1, '', $resp); }
public function collect() { $source = ''; if (false === ($setting = F('tejia_setting'))) { $this->ajaxReturn(0, L('illegal_parameters')); } $p = $this->_get('p', 'intval', 1); if (!$setting['pid']) { $url = 'http://te.tejia.taobao.com/tejia_list.htm?&promotionId=' . $setting['cid'] . '&p=' . $p . '#J_More'; } else { $url = 'http://te.tejia.taobao.com/tejia_list.htm?&promotionId=' . $setting['pid'] . '&cid=' . $setting['cid'] . '&p=' . $p . '#J_More'; } if ($p == 1) { $totalcoll = 0; } else { $totalcoll = F('totalcoll'); } $coll = 0; $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $source = $ftxia_https->results; if (!$source) { $source = file_get_contents($url); } $source = rtrim(ltrim(trim($source), '('), ')'); $source = iconv('GBK', 'UTF-8//IGNORE', $source); if (strpos($source, 'result-non-bd')) { $this->ajaxReturn(0, '该类目暂时没有特价商品'); } if (preg_match_all('/<li class="par-item(.*?)<\\/li>/s', $source, $matchitem)) { for ($i = 0; $i < count($matchitem[1]); $i++) { $item = $matchitem[1][$i]; $title = get_word($item, '<dd class="title">', '<\\/dd>'); $title = preg_replace("/<a[^>]*href=[^>]*>|<\\/[^a]*a[^>]*>/i", "", $title); $img = get_word($item, '<img data-ks-lazyload="', '_210x210.jpg"', ' width="210" height="210"'); $url = get_word($item, '<dd class="title"><a href="', '&f=tejialist"', 'target="_blank">'); preg_match("/id=(\\d*)/", $url, $num); $iid = isset($num[1]) ? $num[1] : ''; $price = get_word($item, '<del>', '<\\/del>'); $zkprice = get_word($item, '<strong>', '<\\/strong>'); $volume = rand(9, 679); $likes = rand(99, 9999); $nick = ''; $ems = '1'; $zekou = get_word($item, '<span class="discount">', '折'); if (!defined(ENDTIME)) { define('ENDTIME', '24'); } if (!$times) { $times = (int) (time() + ENDTIME * 3600); } $tag_list = d("items")->get_tags_by_title($title); $tags = implode(" ", $tag_list); $itemarray['shop_type'] = 'C'; $itemarray['title'] = '' . $title; $itemarray['tags'] = $tags; $itemarray['intro'] = '原价:' . $price . '元,折扣后价格:' . $zkprice . '元,' . $likes . '人觉得不错,目前已有' . $volume . '人参与抢购。'; $itemarray['pic_url'] = $img; $itemarray['num_iid'] = $iid; $itemarray['price'] = $price; $itemarray['coupon_price'] = $zkprice; $itemarray['volume'] = $volume; $itemarray['nick'] = $nick; $itemarray['ems'] = $ems; $itemarray['likes'] = $likes; $itemarray['cate_id'] = $setting['cate_id']; $itemarray['coupon_rate'] = $zekou * 1000; $itemarray['coupon_end_time'] = $times; $itemarray['coupon_start_time'] = time(); if ($title && $img && $iid) { $result['item_list'][] = $itemarray; } } } // exit(print_r($result)); foreach ($result['item_list'] as $key => $val) { $res = $this->_ajax_tb_publish_insert($val); if ($res > 0) { $coll++; } $totalcoll++; } if (strpos($source, '<span class="page-next" title="下一页">')) { $this->ajaxReturn(0, '已经采集完成' . $p . '页,本次采集到' . $totalcoll . '件商品!请返回,谢谢'); } F('totalcoll', $totalcoll); $this->assign('p', $p); $this->assign('coll', $coll); $this->assign('totalnum', $totalnum); $this->assign('totalcoll', $totalcoll); $resp = $this->fetch('collect'); $this->ajaxReturn(1, '', $resp); }
public function collect() { $source = ''; if (false === ($setting = F('advanced_setting'))) { $this->ajaxReturn(0, L('illegal_parameters')); } $p = $this->_get('p', 'intval', 1); if (!$setting['pid']) { $url = 'http://te.tejia.taobao.com/tomorrow_item_list.htm?&promotionId=' . $setting['cid'] . '&p=' . $p . '#J_More'; } else { $url = 'http://te.tejia.taobao.com/tomorrow_item_list.htm?&promotionId=' . $setting['pid'] . '&cid=' . $setting['cid'] . '&p=' . $p . '#J_More'; } if ($p == 1) { $totalcoll = 0; } else { $totalcoll = F('totalcoll'); } $coll = 0; $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $source = $ftxia_https->results; if (!$source) { $source = file_get_contents($url); } $source = rtrim(ltrim(trim($source), '('), ')'); $source = iconv('GBK', 'UTF-8//IGNORE', $source); if (strpos($source, 'result-non-bd')) { $this->ajaxReturn(0, '该类目暂时没有特价商品'); } if (preg_match_all('/<dl>(.*?)<\\/dl>/s', $source, $matchitem)) { for ($i = 0; $i < count($matchitem[1]); $i++) { $item = $matchitem[1][$i]; $title = get_word($item, 'target="_blank">', '<\\/a><\\/dd>'); $img = get_word($item, '<img src="', '_210x210.jpg"', ' width="210" height="210"'); $iid = get_word($item, 'id=', '&f='); $price = get_word($item, '<del>', '<\\/del>'); $zkprice = get_word($item, '<strong>', '<\\/strong>'); $volume = rand(9, 679); $likes = rand(99, 9999); $nick = ''; $ems = '1'; $zekou = round($zkprice / $price, 4); if (date("G") < 10) { $coupon_start_time = strtotime(date("Y-m-d H:i:s", mktime(10, 0, 0, date("m"), date("d"), date("Y")))); $coupon_end_time = strtotime(date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d"), date("Y")))); } else { $coupon_start_time = strtotime(date("Y-m-d H:i:s", mktime(10, 0, 0, date("m"), date("d") + 1, date("Y")))); $coupon_end_time = strtotime(date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") + 1, date("Y")))); } $tag_list = d("items")->get_tags_by_title($title); $tags = implode(" ", $tag_list); $itemarray['shop_type'] = 'C'; $itemarray['title'] = $title; $itemarray['tags'] = $tags; $itemarray['intro'] = '原价:' . $price . '元,折扣后价格:' . $zkprice . '元,' . $likes . '人觉得不错,目前已有' . $volume . '人参与抢购。'; $itemarray['pic_url'] = $img; $itemarray['num_iid'] = $iid; $itemarray['price'] = $price; $itemarray['coupon_price'] = $zkprice; $itemarray['volume'] = $volume; $itemarray['nick'] = $nick; $itemarray['ems'] = $ems; $itemarray['likes'] = $likes; $itemarray['cate_id'] = $setting['cate_id']; $itemarray['coupon_rate'] = $zekou * 10000; $itemarray['coupon_start_time'] = $coupon_start_time; $itemarray['coupon_end_time'] = $coupon_end_time; if ($title && $img && $iid) { $result['item_list'][] = $itemarray; } } } // exit(print_r($result)); foreach ($result['item_list'] as $key => $val) { $res = $this->_ajax_tb_publish_insert($val); if ($res > 0) { $coll++; } $totalcoll++; } if (strpos($source, '<span class="page-next" title="下一页">')) { $this->ajaxReturn(0, '已经采集完成' . $p . '页,本次采集到' . $totalcoll . '件商品!请返回,谢谢'); } F('totalcoll', $totalcoll); $this->assign('p', $p); $this->assign('coll', $coll); $this->assign('totalnum', $totalnum); $this->assign('totalcoll', $totalcoll); $resp = $this->fetch('collect'); $this->ajaxReturn(1, '', $resp); }
public function taobao_collect($date, $p) { M('robots')->where(array('id' => $date['id']))->save(array('last_page' => $p, 'last_time' => time())); $s = ($p - 1) * 44; $q = ''; $tp = F('tp'); if ($p > 1) { if ($p > $tp) { $this->ajaxReturn(0, '已经采集完成' . $tp . '页!请返回,谢谢'); } } if ($p == 1) { $totalcoll = 0; } else { $totalcoll = F('totalcoll'); } if ($date['tb_cid']) { $q .= '&cat=' . $date['tb_cid']; } if ($date['keyword']) { $q .= '&q=' . $date['keyword']; } if ($date['shop_type'] == 'B') { $q .= '&tab=mall'; } else { $q .= '&tab=all'; } if ($date['start_coupon_rate'] && $date['end_coupon_rate'] && $date['start_coupon_rate'] < $date['end_coupon_rate']) { $q .= '&zk_rate=%5B' . $date['start_coupon_rate'] . '%2C' . $date['end_coupon_rate'] . '%5D'; } if ($date['start_price'] && $date['end_price'] && $date['start_price'] < $date['end_price']) { //$q.='&start_price='.$date['start_price'].'&end_price='.$date['end_price']; $q .= '&filter=reserve_price%5B' . $date['start_price'] . '%2C' . $date['end_price'] . '%5D'; } if ($date['sort']) { $sorts = explode("|", $date['sort']); if ($sorts[0] == 'volume') { $sorts[0] = 'sale'; } $q .= '&sort=' . $sorts[0] . '-' . $sorts[1]; } $url = 'http://s.taobao.com/search?commend=all' . $q . '&style=grid&atype=b&limitPromotion=true&filterFineness=2&fs=1&discount_index=1&s=' . $s . '&zk_type=0#J_FilterTabBar'; $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $content = $ftxia_https->results; if (!$content) { $content = file_get_contents($url); } $content = Newiconv("GBK", "UTF-8", $content); $ck = get_word($content, '<li class="home"><a href="http:\\/\\/www.taobao.com\\/">', '<\\/a><\\/li>'); $pre = L('pre'); $totalnum = get_word($content, L($pre . 'total_start'), L($pre . 'total_end')); if (strpos($totalnum, L($pre . 'wang'))) { $totalnum = get_word($content, L($pre . 'total_start'), L($pre . 'total_ends')); $totalnum = $totalnum * 10000; } $tp = intval($totalnum / 40) + 1; F('tp', $tp); if (preg_match_all(L($pre . 'listitem'), $content, $matchitem)) { for ($i = 0; $i < count($matchitem[0]); $i++) { $pi = ($p - 1) * 40 + $i; $msg = '折扣不满足。不采集'; $item = $matchitem[1][$i]; $titlebar = get_word($item, L($pre . 'titlebar_start'), L($pre . 'titlebar_end')); $title = get_word($titlebar, L($pre . 'title_start'), L($pre . 'title_end')); $img = get_word($item, L($pre . 'img_start'), L($pre . 'img_end')); if (!$img) { $img = get_word($item, L($pre . 'imgs_start'), L($pre . 'imgs_end')); if (!$img) { $img = get_word($item, L($pre . 'imgss_start'), L($pre . 'imgss_end')); } } $iid = get_word($item, L($pre . 'iid_start'), L($pre . 'iid_end')); $price = get_word($item, L($pre . 'price_start'), L($pre . 'price_end')); if (!$price) { $pricebar = get_word($item, L($pre . 'pricesssbar_start'), L($pre . 'pricesssbar_end')); $price = get_word($pricebar, L($pre . 'pricesss_start'), L($pre . 'pricesss_end')); } $zkprice = get_word($item, L($pre . 'zkprice_start'), L($pre . 'zkprice_end')); if (!$zkprice) { $zkprice = get_word($item, L($pre . 'zkprices_start'), L($pre . 'zkprices_end')); } if (!$price) { $price = $zkprice; } $volume = get_word($item, L($pre . 'volume_start'), L($pre . 'volume_end')); $nickbar = get_word($item, L($pre . 'nickbar_start'), L($pre . 'nickbar_end')); $nick = get_word($nickbar, L($pre . 'nick_start'), L($pre . 'nick_end')); $ems = get_word($item, L($pre . 'ems_start'), L($pre . 'ems_end')); if (!$ems) { $ems = get_word($item, L($pre . 'emss_start'), L($pre . 'emss_end')); } if ($ems) { if (strpos($ems, L($pre . 'emsor'))) { $ems = '1'; } else { $ems = '0'; } } else { $ems = L('def_ems'); } if (!$volume) { $volume = 0; } $zekou = get_word($item, L($pre . 'zekou_start'), L($pre . 'zekou_end')); if (!$zekou) { $zekou = get_word($item, L($pre . 'zekous_start'), L($pre . 'zekous_end')); if (!$zekou) { $zekou = L('def_coupon_rate'); } } $coupon_add_time = C('ftx_coupon_add_time'); if ($coupon_add_time) { $times = (int) (time() + $coupon_add_time * 3600); } else { $times = (int) (time() + 72 * 86400); } if (strpos($item, 'tmall.com')) { $itemarray['shop_type'] = 'B'; } else { $itemarray['shop_type'] = 'C'; } $itemarray['title'] = $title; $itemarray['pic_url'] = $img; $itemarray['num_iid'] = $iid; $itemarray['price'] = $price; $itemarray['coupon_price'] = $zkprice; $itemarray['volume'] = $volume; $itemarray['nick'] = $nick; $itemarray['ems'] = $ems; $itemarray['cate_id'] = $date['cate_id']; $itemarray['coupon_rate'] = $zekou * 1000; $itemarray['coupon_end_time'] = $times; $itemarray['coupon_start_time'] = time(); if ($title && $img && $iid && $nick) { $result['item_list'][] = $itemarray; } } } else { $result['msg'] = '采集结束!请返回2'; } $taobaoke_item_list = $result['item_list']; $taobaoke_item_list && F('taobaoke_item_list', $taobaoke_item_list); $coll = 0; $thiscount = 0; foreach ($taobaoke_item_list as $key => $val) { $res = $this->_ajax_tb_publish_insert($val); if ($res > 0) { $coll++; $totalcoll++; } $thiscount++; } F('totalcoll', $totalcoll); $result_data['p'] = $p; $result_data['msg'] = $msg; $result_data['coll'] = $coll; $result_data['totalcoll'] = $totalcoll; $result_data['totalnum'] = $totalnum; $result_data['thiscount'] = $thiscount; return $result_data; }
public function taobao_collect($date, $p) { M('robots')->where(array('id' => $date['id']))->save(array('last_page' => $p, 'last_time' => time())); $s = ($p - 1) * 44; $q = ''; $tp = 100; //F('tp');//35732 if ($p > 1) { if ($p > $tp) { $this->ajaxReturn(0, '已经采集完成' . $tp . '页!请返回,谢谢'); } } if ($p == 1) { $totalcoll = 0; } else { $totalcoll = F('totalcoll'); } if ($date['tb_cid']) { $q .= '&cat=' . $date['tb_cid']; } if ($date['keyword']) { $q .= '&q=' . $date['keyword']; } if ($date['shop_type'] == 'B') { $q .= '&tab=mall&isprepay=1'; } else { $q .= '&tab=all&apassall=1'; } if ($date['start_price'] && $date['end_price'] && $date['start_price'] < $date['end_price']) { $q .= '&filter=reserve_price%5B' . $date['start_price'] . '%2C' . $date['end_price'] . '%5D'; } if ($date['sort']) { $sorts = explode('|', $date['sort']); if ($sorts[0] == 'volume') { $sorts[0] = 'sale'; } $q .= '&sort=' . $sorts[0] . '-' . $sorts[1]; } $url = 'http://s.taobao.com/search?' . $q . '&style=grid&fs=0&cps=yes&initiative_id=staobaoz_20140606&promote=0&s=' . $s . '#J_relative'; $ftxia_https = new ftxia_https(); $ftxia_https->fetch($url); $content = $ftxia_https->results; if (!$content) { $content = file_get_contents($url); } $content = Newiconv("GBK", "UTF-8", $content); $ck = get_word($content, '<li class="home"><a href="http:\\/\\/www.taobao.com\\/">', '<\\/a><\\/li>'); $pre = L('pre'); $totalnum = get_word($content, L($pre . 'total_start'), L($pre . 'total_end')); $tp = intval($totalnum / 44) + 1; if (preg_match_all(L($pre . "listitem"), $content, $matchitem)) { //44 $mtmp = array(); for ($i = 0; $i < count($matchitem[0]); $i++) { $pi = ($p - 1) * 44 + $i; $msg = '折扣不满足。不采集'; $item = $matchitem[1][$i]; $titlebar = get_word($item, L($pre . 'titlebar_start'), L($pre . 'titlebar_end')); $title = get_word($titlebar, L($pre . 'title_start'), L($pre . 'title_end')); $img = get_word($item, L($pre . 'img_start'), L($pre . 'img_end')); if (!$img) { $img = get_word($item, L($pre . 'imgs_start'), L($pre . 'imgs_end')); if (!$img) { $img = get_word($item, L($pre . 'imgss_start'), L($pre . 'imgss_end')); } } $iid = get_word($item, L($pre . 'iid_start'), L($pre . 'iid_end')); $price = get_word($item, L($pre . 'price_start'), L($pre . 'price_end')); if (!$price) { $price = get_word($item, L($pre . 'prices_start'), L($pre . 'prices_end')); } if (!$price) { $price = get_word($item, L($pre . 'pricess_start'), L($pre . 'pricess_end')); } if (!$price) { $pricebar = get_word($item, L($pre . 'pricesssbar_start'), L($pre . 'pricesssbar_end')); $price = get_word($pricebar, L($pre . 'pricesss_start'), L($pre . 'pricesss_end')); } $zkprice = get_word($item, L($pre . 'zkprice_start'), L($pre . 'zkprice_end')); if (!$price) { $price = $zkprice; } $volume = get_word($item, L($pre . 'volume_start'), L($pre . 'volume_end')); $hits = get_word($item, L($pre . 'hits_start'), L($pre . 'hits_end')); $nick = get_word($item, L($pre . 'nick_start'), L($pre . 'nick_end')); $nick = urldecode($nick); $ems = get_word($item, L($pre . 'ems_start'), L($pre . 'ems_end')); if (!$ems) { $ems = get_word($item, L($pre . 'emss_start'), L($pre . 'emss_end')); } if ($ems) { if ($pre == 'hk_') { if (strpos($ems, '免運費')) { $ems = '1'; } else { $ems = '0'; } } else { if (strpos($ems, '免运费')) { $ems = '1'; } else { $ems = '0'; } } } else { $ems = '1'; } if (!$volume) { $volume = 0; } $zekou = round($zkprice / $price * 10, 1); $coupon_add_time = C('ftx_coupon_add_time'); if ($coupon_add_time) { $times = (int) (time() + $coupon_add_time * 3600); } else { $times = (int) (time() + 72 * 86400); } if (strpos($item, 'tmall.com')) { $itemarray['shop_type'] = 'B'; } else { $itemarray['shop_type'] = 'C'; } $volume = trim($volume); $volume = str_ireplace('人付款', '', $volume); $price = trim($price); $price = str_ireplace('<i>¥</i>', '', $price); $tag_list = d("items")->get_tags_by_title($title); $tags = implode(" ", $tag_list); $zkprice = trim($zkprice); $zkprice = str_ireplace('<i>¥</i>', '', $zkprice); $itemarray['title'] = $title; $itemarray['intro'] = '强烈推荐:' . $title . ',优惠活动折扣价格:' . $zkprice . '元,已成交:' . $volume . '笔。'; $itemarray['pic_url'] = $img; $itemarray['num_iid'] = $iid; $itemarray['hits'] = $hits; $itemarray['price'] = $price; $itemarray['likes'] = rand(99, 9999); $itemarray['coupon_price'] = $zkprice; $itemarray['volume'] = $volume; $itemarray['nick'] = $nick; $itemarray['tags'] = $tags; $itemarray['ems'] = $ems; $itemarray['cate_id'] = $date['cate_id']; $itemarray['coupon_rate'] = $zekou * 1000; $itemarray['coupon_end_time'] = $times; $itemarray['coupon_start_time'] = time(); if ($title && $img && $iid) { $result['item_list'][] = $itemarray; } //exit(print_r($itemarray)); } } else { $result['msg'] = '采集结束!请返回2'; } $taobaoke_item_list = $result['item_list']; $taobaoke_item_list && F('taobaoke_item_list', $taobaoke_item_list); $coll = 0; $thiscount = 0; foreach ($taobaoke_item_list as $key => $val) { $res = $this->_ajax_tb_publish_insert($val); if ($res > 0) { $coll++; $totalcoll++; } $thiscount++; } F('totalcoll', $totalcoll); $result_data['p'] = $p; $result_data['msg'] = $msg; $result_data['coll'] = $coll; $result_data['totalcoll'] = $totalcoll; $result_data['totalnum'] = $totalnum; $result_data['thiscount'] = $thiscount; return $result_data; }