我试图在抓取我的html页面后从phpquery获取节点值。
$doc = phpQuery::newDocumentFileHTML('myurl');
foreach($doc['#filter-reload.row h1'] as $value)
{
print_r($value);
exit;
}
我的输出为
DOMElement Object ( [tagName] => h1 [schemaTypeInfo] => [nodeName] => h1
[nodeValue] => Oz The Great And Powerful (PG) [nodeType] => 1 [parentNode] => (object value omitted)
[childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => (object value omitted)
我只想将nodeValue作为输出......但是得到它呢?
我试过了: -
$doc['#filter-reload.row h1']->nodeValue //not working
$doc['#filter-reload.row h1']['nodeValue']//notworking
答案 0 :(得分:3)
试试这个它会起作用.......
$doc = phpQuery::newDocumentFileHTML('myurl');
$new_data = array();
foreach($doc['#filter-reload.row h1'] as $value)
{
$new_data[] = $value->nodeValue;
}