开发者

PHP HTML DOM Parser [duplicate]

开发者 https://www.devze.com 2023-01-27 17:43 出处:网络
This question already has answers here: 开发者_StackOverflow中文版Closed 10 years ago. Possible Duplicate:
This question already has answers here: 开发者_StackOverflow中文版 Closed 10 years ago.

Possible Duplicate:

How to parse and process HTML with PHP?

I'm looking into HTML DOM parsers for PHP. I've found PHP Simple HTML DOM Parser. Are there any others I should be looking at?


Yes. Simple html doc is fine, but an order of magnitude slower than the built in dom parser.

$dom = new DOMDocument();
@$dom->loadHTML($html);
$x = new DOMXPath($dom); 

foreach($x->query("//a") as $node) 
{
    $data['dom']['href'][] = $node->getAttribute("href");
} 

Use that.


You can look at the builtin DOM

http://php.net/dom


Recently I also found ganon, but in general PHP Simple HTML DOM Parser is the best!

0

精彩评论

暂无评论...
验证码 换一张
取 消