了解phpQuery使用前了温习jquery.js的选择用法 jquery选择器,还有一个衍生产品QueryList

例:

include 'phpQuery.php'; 
phpQuery::newDocumentFile('http://www.phper.org.cn'); 
echo pq("title")->text();    // 获取网页标题
echo pq("div#header")->html();    // 获取id为header的div的html内容

例获取某品牌的logo

      echo '<pre>';
       $target_url = 'http://www.jinxiang.com/brandmap.html';       
       phpQuery::newDocumentFile($target_url);
       $list = pq('div#brandList')->find('li');
       $i = 0;
       $img_src_list = array();
       foreach ($list as $item) {
           $i ++;
           $img = pq($item)->find('img')->attr('src');           
           $img_src_list[] = $img;
       }
       var_dump($img_src_list);    

 

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2022-01-07
  • 2021-09-26
  • 2022-12-23
  • 2021-11-05
猜你喜欢
  • 2021-10-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2021-09-22
  • 2022-01-29
相关资源
相似解决方案