美文网首页
php强大的采集器phpQuery

php强大的采集器phpQuery

作者: f09037cb27f7 | 来源:发表于2017-08-09 09:55 被阅读94次

phpQuery代码地址 https://github.com/phpquery/phpquery

<?  
include 'phpQuery.php';  
phpQuery::newDocumentFile('http://www.xiaophp.cn');  
$companies = pq('#hotcoms .coms')->find('div');  
foreach($companies as $company)  
{  
   echo pq($company)->find('h3 a')->text()."<br>";  
}  
参数 描述 默认值
* 所有元素 $("*")
#id id="lastname" 的元素 $("#lastname")
.class 所有 class="intro" 的元素 $(".intro")
element 所有 <p> 元素 $("p")
.class.class 所有 class="intro" 且 class="demo" 的元素 $(".intro.demo")
:first 第一个 <p> 元素 $("p:first")
:last 最后一个 <p> 元素 $("p:last")
:even 所有偶数 <tr> 元素 $("tr:even")
:odd 所有奇数 <tr> 元素 $("tr:odd")
:eq(index) 列表中的第四个元素(index 从 0 开始) $("ul li:eq(3)")
:gt(no) 列出 index 大于 3 的元素 $("ul li:gt(3)")
:lt(no) 列出 index 小于 3 的元素 $("ul li:lt(3)")
:not(selector) 所有不为空的 input 元素 $("input:not(:empty)")
:header 所有标题元素 <h1> - <h6> $(":header")
:animated 所有动画元素
:contains(text) 包含指定字符串的所有元素 $(":contains('W3School')")
:empty 无子(元素)节点的所有元素 $(":empty")
:hidden 所有隐藏的 <p> 元素 $("p:hidden")
:visible 所有可见的表格 $("table:visible")
s1,s2,s3 所有带有匹配选择的元素 $("th,td,.intro")
[attribute] 所有带有 href 属性的元素 $("[href]")
[attribute=value] 所有 href 属性的值等于 "#" 的元素 $("[href='#']")
[attribute!=value] 所有 href 属性的值不等于 "#" 的元素 $("[href!='#']")
[attribute$=value] 所有 href 属性的值包含以 ".jpg" 结尾的元素 $("[href$='.jpg']")
:input 所有 <input> 元素 $(":input")
:text 所有 type="text" 的 <input> 元素 $(":text")
:password 所有 type="password" 的 <input> 元素 $(":password")
:radio 所有 type="radio" 的 <input> 元素 $(":radio")
:checkbox 所有 type="checkbox" 的 <input> 元素 $(":checkbox")
:submit 所有 type="submit" 的 <input> 元素 $(":submit")
:reset 所有 type="reset" 的 <input> 元素 $(":reset")
:button 所有 type="button" 的 <input> 元素 $(":button")
:image 所有 type="image" 的 <input> 元素 $(":image")
:file 所有 type="file" 的 <input> 元素 $(":file")
:enabled 所有激活的 input 元素 $(":enabled")
:disabled 所有禁用的 input 元素 $(":disabled")
:selected 所有被选取的 input 元素 $(":selected")
:checked 所有被选中的 input 元素 $(":checked")

相关文章

网友评论

      本文标题:php强大的采集器phpQuery

      本文链接:https://www.haomeiwen.com/subject/qejfrxtx.html