html-parserPHP 的 HTML 解析工具
php html解析工具,类似PHP Simple HTML DOM Parser。 由于基于php模块tidy,所以在解析html时的效率比 PHP Simple HTML DOM Parser 快2倍多。 并提供广度优先查询find()和深度优先查询find2() 两种查询方式,可根据自己的情况选择使用。 因为代码实现的问题,在查询全部时深度优先比广度优先快一点。
示例代码:
<?php $html = '<html> <head> <title>test</title> </head> <body> <p class="test_class test_class1">p1</p> <p class="test_class test_class2">p2</p> <p class="test_class test_class3">p3</p> <div id="test1">测试1</div> </body> </html>'; $html_dom = new HtmlParserModel(); $html_dom->parseStr($html); $p_array = $html_dom->find('p.test_class'); $p1 = $html_dom->find('p.test_class1',0); $div = $html_dom->find('div#test1',0); foreach ($p_array as $p){ echo $p->getPlainText(); } echo $div->getPlainText(); echo $p1->getPlainText(); echo $pi->class; ?>
评论
htmlspriteFlash的HTML解析
htmlsprite是一个Flash用来解析HTML文档的开发包。示例代码:importcom.redurban.HTMLSpritevarhtmlsprite:HTMLSprite=newHTMLS
htmlspriteFlash的HTML解析
0
mechanizePython的HTML解析
当您希望与Web页面中找到的内容进行某种比较复杂的交互时,您需要使用mechanize库示例代码:importrefrommechanizeimportBrowserbr=Browser()br.op
mechanizePython的HTML解析
0
wiseparserPHP的HTML解析
wiseparser是一个PHP语言用来解析HTML文档的开发包。示例代码:require_once('treebuilder.php');$mytree=newTree();<br>$m
wiseparserPHP的HTML解析
0