示例#1
0
 function _itoolsSave($lis, $type)
 {
     foreach ($lis as $k => $li) {
         $array['title'] = pq($li)->find('.ios_app_cur')->find('.ios_app_curTxt')->eq(0)->text();
         $array['ranking'] = $k + 1;
         $array['type'] = $type;
         $array['searchtime'] = date("Y-m-d H:i:s");
         $tongji = new TongjiData();
         $tongji->insertData($array);
     }
 }
示例#2
0
 private function _tryGetAishiData($url, $page, $pagesize = 20, $count = 3)
 {
     $url = $url . '&pageno=' . $page;
     $xml = Crawler::curl($url);
     $have_utf = false;
     if (strpos($xml, 'UTF-8') != false) {
         $have_utf = true;
     }
     if (strpos($xml, 'utf-8') != false) {
         $have_utf = true;
     }
     if ($have_utf == false) {
         return array();
     }
     $xml = simplexml_load_string($xml);
     if ($xml) {
         //首页banner入库
         if ($page == 1 && isset($xml->adlist)) {
             $b = 0;
             foreach ($xml->adlist->adinfo as $v) {
                 $banner['title'] = $v->name;
                 $banner['ranking'] = ++$b;
                 $banner['type'] = 13;
                 $banner['searchtime'] = date("Y-m-d H:i:s");
                 $tongji = new TongjiData();
                 $tongji->insertData($banner);
             }
         }
         $k = 0;
         foreach ($xml->applist->app as $v) {
             $datas[$k]['title'] = $v->appname;
             $datas[$k]['ranking'] = ($page - 1) * $pagesize + $k + 1;
             $k++;
         }
         return $datas;
     } elseif ($count !== 0) {
         $count--;
         sleep(1);
         return $this->_tryGetAishiData($url, $page, $count);
     }
     return array();
 }