function insert_to_vm_panda($id_category, $UURRLL) { global $conn; pq_page($UURRLL); $res_items = pq('ul.products-grid>li'); foreach ($res_items as $item) { try { $ii = pq($item); $hhq = $ii->html(); $productUrl = $ii->find('a.product-image')->attr('href'); $sql1 = "select count(*) as count from _products where url='{$productUrl}' limit 1"; $res = run_sql($sql1); // $res = mysql_query($sql1, $conn)or die("Invalid query: " . mysql_error());; $data = mysql_fetch_assoc($res); if ($data[count] == 0) { $imgSmallUrl = $ii->find("img")->attr('taikoo_lazy_src'); $product_name = $ii->find('.product-name>a')->text(); $product_sql = "INSERT _products (url, ids_category, name, img_small, status)\n VALUES ('{$productUrl}', {$id_category}, '{$product_name}', '{$imgSmallUrl}', 1)"; run_sql($product_sql); } else { $sql1 = "select * from _products where url='{$productUrl}' limit 1"; $res = run_sql($sql1); $data2 = mysql_fetch_assoc($res); $category_old_value = (string) $data2[ids_category]; $sql = " UPDATE _products SET ids_category='{$category_old_value},{$id_category}' WHERE url='{$productUrl}'"; run_sql($sql); } } catch (Exception $exc) { echo $exc->getTraceAsString(); } } return $res; }
function pars_filters($url, $id_filter, $category_id) { pq_page($url); $filters = pq(".pw_item"); foreach ($filters as $filter) { $item = pq($filter); $filter_name = $item->find("h3")->text(); if (!($filter_name == "Price" or $filter_name == "With Play Store")) { $filter_items = $item->find("li>a"); foreach ($filter_items as $filter_item) { $item_name = pq($filter_item)->text(); $item_url = pq($filter_item)->attr('href'); $query = "insert into _filters ( `name`,category_id,url,`group`,id_group)\n values ('{$item_name}',{$category_id},'{$item_url}','{$filter_name}',{$id_filter}) "; mysql_query($query); } $id_filter++; } } return $id_filter; }
require 'controler.php'; //global $HOST, $USER, $PASS, $DB; $mysqli = new mysqli($HOST, $USER, $PASS, $DB); if ($mysqli->connect_error) { die('Ошибка соединения (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } $tabVM = '_products'; $qUrl = "SELECT * FROM {$tabVM} WHERE status=1 and id>5500 and id<6000"; $res_Url = $mysqli->query($qUrl); $j = 0; while ($row = $res_Url->fetch_array()) { $ID_PRODUCT = $row['id']; $URL = $row['url']; // $ID_PRODUCT = 4032; // $URL = "http://www.pandawill.com/laaboo-w01-smartphone-mtk6582-quad-core-1gb-8gb-50-inch-ips-screen-80mp-camera-p101271.html"; pq_page($URL); $PRICE = trim(pq('span.price:first')->text()); $PRICE = str_replace('$', '', $PRICE); // Описание $tabsParametr = pq('ul#cjpro_ul>li:eq(1)')->text(); if ($tabsParametr == "Parameter") { $DESCR = pq('div.cjpro_wen:eq(1)'); } else { $DESCR = pq('div.cjpro_wen:eq(0)'); } // $DESCR=$DESCR->find("*")->removeAttr("style"); // $DESCR=$DESCR->find("*")->removeAttr("height"); // $DESCR=$DESCR->find("*")->removeAttr("width"); // $DESCR=$DESCR->find("*")->removeAttr("class"); $allStoryImges = $DESCR->find('img'); $ii = 0;