gpt4 book ai didi

php - 使用 PHP 从其他网站解析(无效)HTML

转载 作者:可可西里 更新时间:2023-11-01 01:08:10 24 4
gpt4 key购买 nike

我正在尝试从以下 URL 解析以下 HTML:

http://md5.rednoize.com/?q=fbade9e36a3f36d3d676c1b808451dd7

代码:

    $html = file_get_contents($url.$hash);
$config = array(
'clean' => 'yes',
'output-html' => 'yes',
);
$tidy = tidy_parse_string($html, $config, 'utf8');
$tidy->cleanRepair();
$dom = new DOMDocument;
$dom->loadHTML($tidy);

$result = $dom->getElementById('result');

然而它是无效的:

Warning: DOMDocument::loadHTML() [<a href='domdocument.loadhtml'>domdocument.loadhtml</a>]: ID switcher already defined in Entity, line: 128 in

有没有办法仍然能够解析它?

最佳答案

您可以在关闭严格错误检查后尝试解析它:

$dom = new DOMDocument;
$dom->strictErrorChecking = FALSE;
$dom->loadHTML($tidy);

关于php - 使用 PHP 从其他网站解析(无效)HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6637125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com