首页 > 解决方案 > 为什么这个带有 getAttribute 的 PHP DOM 解析不起作用?

问题描述

从这个页面,我想得到带有名字valueinput标签form_key。但我收到以下错误:

Fatal error: Uncaught Error: Call to undefined method simple_html_dom::getAttribute() in test.php:9 Stack trace: #0 {main} thrown in test.php on line 9

请注意,我使用的是 PHP Simple DOM 解析器。

PHP:

include('simple_html_dom.php');

$html = file_get_html('https://b2b.chiemsee.com/customer/account/login/');

if($html->getAttribute('name') =='form_key'){
    echo $html->nodeValue;
}

标签: phphtmlparsingdomhtml-parsing

解决方案


推荐阅读