You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
949 B

2 years ago
  1. # phpQuery-single
  2. phpQuery onefile composer.Continuous maintenance,Welcome PR.
  3. `QueryList` base on phpQuery: https://github.com/jae-jae/QueryList
  4. phpQuery单文件版本,持续维护,欢迎PR.
  5. > phpQuery项目主页:http://code.google.com/p/phpquery/
  6. `QueryList`是基于phpQuery的采集工具: https://github.com/jae-jae/QueryList
  7. ## Composer Installation
  8. Packagist: https://packagist.org/packages/jaeger/phpquery-single
  9. ```
  10. composer require jaeger/phpquery-single
  11. ```
  12. ## Usage
  13. ```php
  14. $html = <<<STR
  15. <div id="one">
  16. <div class="two">
  17. <a href="http://querylist.cc">QueryList官网</a>
  18. <img src="http://querylist.cc/1.jpg" alt="这是图片">
  19. <img src="http://querylist.cc/2.jpg" alt="这是图片2">
  20. </div>
  21. <span>其它的<b>一些</b>文本</span>
  22. </div>
  23. STR;
  24. $doc = phpQuery::newDocumentHTML($html);
  25. $src = $doc->find('.two img:eq(0)')->attr('src');
  26. echo $src;
  27. // http://querylist.cc/1.jpg
  28. ```