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>";
}
參數(shù) | 描述 | 默認(rèn)值 |
---|---|---|
* | 所有元素 | $("*") |
#id | id="lastname" 的元素 | $("#lastname") |
.class | 所有 class="intro" 的元素 | $(".intro") |
element | 所有 <p> 元素 | $("p") |
.class.class | 所有 class="intro" 且 class="demo" 的元素 | $(".intro.demo") |
:first | 第一個(gè) <p> 元素 | $("p:first") |
:last | 最后一個(gè) <p> 元素 | $("p:last") |
:even | 所有偶數(shù) <tr> 元素 | $("tr:even") |
:odd | 所有奇數(shù) <tr> 元素 | $("tr:odd") |
:eq(index) | 列表中的第四個(gè)元素(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 | 所有標(biāo)題元素 <h1> - <h6> | $(":header") |
:animated | 所有動(dòng)畫元素 | |
:contains(text) | 包含指定字符串的所有元素 | $(":contains('W3School')") |
:empty | 無子(元素)節(jié)點(diǎn)的所有元素 | $(":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" 結(jié)尾的元素 | $("[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") |