phpQuery的一些学习笔记

Writer @ ybzai 2020-03-21 22:48 阅读(1216)

phpQuery::newDocumentFile($htmlFile);   //之后

phpQuery::$documents = array();
//或者unset(phpQuery::$documents);

while (true) {
    phpQuery::newDocumentFile($htmlFile);
    // 处理网页元素...
    phpQuery::$documents = array();
    echo memory_get_usage() . "\n";    //获取内存消耗量
}

例子:

phpQuery::newDocumentFileXHTML('my-xhtml.html')->find('p'); 
$ul = pq('ul');
phpQuery :: newDocument($ html,$ contentType = null)//从标记创建新文档。如果没有$ contentType,//则自动检测(基于标记)。如果失败,则使用utf-8中的text / html。
phpQuery :: newDocumentFile($ file,$ contentType = null)//从文件创建新文档。像newDocument()
phpQuery :: newDocumentHTML($ html,$ charset ='utf-8')
phpQuery :: newDocumentXHTML($ html,$ charset ='utf-8')
phpQuery :: newDocumentXML($ html,$ charset ='utf-8')
phpQuery :: newDocumentPHP($ html,$ contentType = null)
phpQuery :: newDocumentFileHTML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFileXHTML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFileXML($ file,$ charset ='utf-8')
phpQuery :: newDocumentFilePHP($ file,$ contentType)

PQ(); 函数相当于jQuery的$(); 。它用于3种类型的东西:1.导入标记1.运行查询1.使用phpQuery对象包装DOMNodes

标签: PHP

感谢赞赏

微信支付
微信支付
支付宝
支付宝