PHP HTML DOM Parser [duplicate]

2020-02-10 03:23发布

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?

3条回答
爷的心禁止访问
2楼-- · 2020-02-10 04:03

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.

查看更多
疯言疯语
3楼-- · 2020-02-10 04:09

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

查看更多
一夜七次
4楼-- · 2020-02-10 04:17

You can look at the builtin DOM

http://php.net/dom

查看更多
登录 后发表回答