我正在使用这个库(PHP Simple HTML DOM解析器)来解析链接,这里是代码:
$html = getHTMLContentFromURL ( $url, $requestHeaders );
foreach ( $html->find ( '#listStack' ) as $e ) {
$stacks = split('split', $e);
$values = array_shift($stacks);
foreach ($stacks as $stack) {
foreach ( $stack->find ( 'b' ) as $e1 ) {
$id = strip_tags ( $e1->innertext );
}
foreach ( $stack->find ( 'a' ) as $e2 ) {
$link = strip_tags ( $e2->href );
$title = strip_tags ( $e2->innertext );
}
}
但输出结果时出现此错误:
致命错误:在非对象中调用成员函数find() 第108行的C:\ xampp \ htdocs \ parser.php
Line 108 is the foreach ( $stack->find ( 'b' ) as $e1 )