【发布时间】:2014-05-08 17:11:24
【问题描述】:
我正在尝试从谷歌搜索接收价格数据,这段代码给了我一个“尝试获取非对象的属性”
<?php
$html = file_get_contents('http://www.google.com/#q=ps3&tbm=shop'); //get the html returned from the following url
$glist = array();
$gdoc = new DOMDocument();
libxml_use_internal_errors(TRUE); //disable libxml errors
if(!empty($html)){ //if any html is actually returned
$gdoc->loadHTML($html);
libxml_clear_errors(); //remove errors for yucky html
$gxpath = new DOMXPath($gdoc);
$name = $gxpath->query('b')->item(0)->nodeValue;
}
echo "<pre>";
print_r($glist);
echo "</pre>";
?>
任何帮助都会很好!
【问题讨论】: