phpQuery强大的采集器【原创

来源:https://www.sucaihuo.com/php/178.html 2015-06-11 22:37浏览(6317) 收藏

phpquery是一款强大的php小偷采集插件,它的用法和jQuery库获取对象一致。
phpQuery强大的采集器
分类:PHP > 插件 难易:中级
下载资源 下载积分: 288 积分

PHP

require 'QueryList.class.php';

$pattern = array("title" => array(".joke-title a", "text"),"href" => array(".joke-title a", "href"));
$url = "http://www.mahua.com/";
$qy = new QueryList($url, $pattern, '', '', 'utf-8');
$rs = $qy->jsonArr;
$ul = "<ul>";
foreach($rs as $v){
    $ul .= "<li><a href='".$v['href']."' target='_blank'>".$v['title']."</li>";
}
$ul .= "</ul>";

phpquery获取对象API

参数 描述 默认值
* 所有元素 $("*")
#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")
声明:本文为原创文章,如需转载,请注明来源sucaihuo.com并保留原文链接:https://www.sucaihuo.com/php/178.html
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2