phpQuery强大的采集器

phpQuery强大的采集器

phpQuery强大的采集器

phpquery是一款强大的php小偷采集插件,它的用法和jQuery库获取对象一致。

源码介绍

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 = "
    "; 
    foreach($rs as $v){ 
        $ul .= "
  • .$v['href']."' target='_blank'>".$v['title']."
  • "


    $ul .= "
"
;

               

phpquery获取对象API

元素 元素
参数描述默认值
*所有元素$("*")
#idid="lastname" 的元素$("#lastname")
.class所有 class="intro" 的元素$(".intro")
element所有

元素

$("p")
.class.class所有 class="intro" 且 class="demo" 的元素$(".intro.demo")
:first第一个

元素

$("p:first")
:last最后一个

元素

$("p:last")
:even所有偶数
$("tr:even")
:odd所有奇数
$("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所有标题元素

-

$(":header")
:animated所有动画元素
:contains(text)包含指定字符串的所有元素$(":contains('W3School')")
:empty无子(元素)节点的所有元素$(":empty")
:hidden所有隐藏的

元素

$("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")
:text所有 type="text" 的 元素$(":text")
:password所有 type="password" 的 元素$(":password")
:radio所有 type="radio" 的 元素$(":radio")
:checkbox所有 type="checkbox" 的 元素$(":checkbox")
:submit所有 type="submit" 的 元素$(":submit")
:reset所有 type="reset" 的 元素$(":reset")
:button所有 type="button" 的 元素$(":button")
:image所有 type="image" 的 元素$(":image")
:file所有 type="file" 的 元素$(":file")
:enabled所有激活的 input 元素$(":enabled")
:disabled所有禁用的 input 元素$(":disabled")
:selected所有被选取的 input 元素$(":selected")
:checked所有被选中的 input 元素$(":checked")


分享到 :

发表评论

登录... 后才能评论