コード例 #1
0
 public function getLiUrlList($id)
 {
     $flag = phpQuery::newDocumentFileHTML('http://www.255y.com/list_' . $id . '.html', 'GBK');
     if ($flag === FALSE) {
         die('404');
     }
     $h2 = pq("h2");
     $li_url_list = array();
     foreach ($h2 as $li) {
         $li_url_info = array();
         $a = pq($li)->find('a');
         $li_url_info['name'] = $a->attr('title');
         $li_url_info['url'] = $a->attr('href');
         $li_url_list[] = $li_url_info;
     }
     phpQuery::clear();
     return $li_url_list;
 }
コード例 #2
0
 public function getImgUrlListByLiId($url)
 {
     $keep_url = NULL;
     $flag = phpQuery::newDocumentFileHTML($url, 'GBK');
     if ($flag === FALSE) {
         return FALSE;
     }
     $pq_img = pq("div.m-list-content")->find('p');
     if (pq($pq_img)->find('a')->html()) {
         $pq_img = pq($pq_img)->find('a');
         $uri = $pq_img->attr('href');
         $url_info = parse_url($url);
         $_path = explode('/', $url_info['path']);
         $keep_url = $url_info['scheme'] . '://' . $url_info['host'] . '/' . $_path[1] . '/' . $uri;
     }
     $this->img_url_list[] = array('img_url' => pq($pq_img)->find('img')->attr('src'), 'li_id' => $this->img_li_id);
     phpQuery::clear();
     if ($keep_url != NULL) {
         $this->getImgUrlListByLiId($keep_url);
     }
     return $this->img_url_list;
 }