phpQuery下载—包含官方完整使用文档

模板网 2014-10-07

phpQuery下载—包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。

下载地址:phpQuery下载—包含官方完整使用文档

官方下载地址:https://code.google.com/p/phpquery/

下载压缩包截图:

phpQuery下载—包含官方完整使用文档

官方提供的demo代码:

复制代码 代码如下:
<?php
require('phpQuery/phpQuery.php');
 
// INITIALIZE IT
// phpQuery::newDocumentHTML($markup);
// phpQuery::newDocumentXML();
// phpQuery::newDocumentFileXHTML('test.html');
// phpQuery::newDocumentFilePHP('test.php');
// phpQuery::newDocument('test.xml', 'application/rss+xml');
// this one defaults to text/html in utf8
$doc = phpQuery::newDocument('<div/>');
 
// FILL IT
// array syntax works like ->find() here
$doc['div']->append('<ul></ul>');
// array set changes inner html
$doc['div ul'] = '<li>1</li> <li>2</li> <li>3</li>';
 
// MANIPULATE IT
$li = null;
// almost everything can be a chain
$doc['ul > li']
->addClass('my-new-class')
->filter(':last')
->addClass('last-li')
// save it anywhere in the chain
->toReference($li);
 
// SELECT DOCUMENT
// pq(); is using selected document as default
phpQuery::selectDocument($doc);
// documents are selected when created or by above method
// query all unordered lists in last selected document
$ul = pq('ul')->insertAfter('div');
 
// ITERATE IT
// all direct LIs from $ul
foreach($ul['> li'] as $li) {
// iteration returns PLAIN dom nodes, NOT phpQuery objects
$tagName = $li->tagName;
$childNodes = $li->childNodes;
// so you NEED to wrap it within phpQuery, using pq();
pq($li)->addClass('my-second-new-class');
}
 
// PRINT OUTPUT
// 1st way
print phpQuery::getDocument($doc->getDocumentID());
// 2nd way
print phpQuery::getDocument(pq('div')->getDocumentID());
// 3rd way
print pq('div')->getDocument();
// 4th way
print $doc->htmlOuter();
// 5th way
print $doc;
// another...
print $doc['ul'];

 

相关文章

  1. phpQuery下载—包含官方完整使用文档

    phpQuery下载包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。 下载地址: phpQuery下载包含官方完整使用文档 官方下载地址: https://code.google.com/p/phpquery/ 下载压缩包截图: 官方提供的demo代码: 复制代码

  2. 帝国备份王(Empirebak)详细使用说明文档

    EmpireBak是一款完全开源免费、专门为Mysql大数据的备份与导入而设计的软件,系统采用分卷备份与导入,理论上可备份任何大小的数据库.

  3. PHP date函数输出时间少8小时的解决方法

    使用某些PHP服务器套件开发PHP程序的时候,调用date函数输出时间会少8小时,下面提供一个解决的方法。

  4. dedecms中提取的zip压缩文件操作类zip.class.php

    从织梦DeDeCMS中提取的zip压缩文件操作类,包含zip文件压缩、解压缩、添加文件到压缩包中等多个实用的函数,注释详细方便使用。 下载: dedecms中提取的zip压缩文件操作类zip.class.php 包含的函数和简单的使用方法: 1.函数get_List($zip_name) ,函数作用

  5. php判断一个页面是否被删除判断返回404

    复制代码 代码如下: ?php function get404($urla){ $headers = get_headers($urla); $htt = $headers[3]; $silingsi = 404; if(stripos($htt,$silingsi,0)== false){ $shoulu = 正常; return $shoulu; break; }else{ $shoulu = 404; return $shoulu; break;

随机推荐

  1. phpQuery下载—包含官方完整使用文档

    phpQuery下载包含官方完整使用文档。phpQuery是一个类似jQuery的php网页采集类库,使用方法非常简单。 下载地址: phpQuery下载包含官方完整使用文档 官方下载地址: https://code.google.com/p/phpquery/ 下载压缩包截图: 官方提供的demo代码: 复制代码

  2. 帝国备份王(Empirebak)详细使用说明文档

    EmpireBak是一款完全开源免费、专门为Mysql大数据的备份与导入而设计的软件,系统采用分卷备份与导入,理论上可备份任何大小的数据库.

  3. PHP date函数输出时间少8小时的解决方法

    使用某些PHP服务器套件开发PHP程序的时候,调用date函数输出时间会少8小时,下面提供一个解决的方法。

  4. dedecms中提取的zip压缩文件操作类zip.class.php

    从织梦DeDeCMS中提取的zip压缩文件操作类,包含zip文件压缩、解压缩、添加文件到压缩包中等多个实用的函数,注释详细方便使用。 下载: dedecms中提取的zip压缩文件操作类zip.class.php 包含的函数和简单的使用方法: 1.函数get_List($zip_name) ,函数作用

  5. php判断一个页面是否被删除判断返回404

    复制代码 代码如下: ?php function get404($urla){ $headers = get_headers($urla); $htt = $headers[3]; $silingsi = 404; if(stripos($htt,$silingsi,0)== false){ $shoulu = 正常; return $shoulu; break; }else{ $shoulu = 404; return $shoulu; break;