对信息采集很有用,当然也产生了大量重复信息
在 thinkphp3.2.2中使用phpQuery 有一个问题见
thinkphp问题记录phpQuery使用错误
这回又遇到一个问题了,用class方式查询出某div的循环列表后,想用数组的方式保存div中的某些字段,如:
$doc = \phpQuery::newDocumentFile('C:/xampp/htdocs/sae/st/text.htm');
$piclist = pq(".p-cell.cellItem");
foreach ($piclist as $pic) {
$picurl = pq($pic)->find('.pic img')->attr('src');
$pictitle = pq($pic)->find('span.cellTit')->html();
//以下两行会报错 Cannot use object of type DOMElement as array
$pic['src'] = $picurl;
$pic['name'] = $pictitle;
//正确的使用方式, 参见 http://www.wallpaperama.com/forums/howto-fix-fatal-error-cannot-use-object-of-type-stdclass-as-array-in-php-t1735.html
//$pic->name = $pictitle;
//$pic->src = $picurl;
}
参考 http://www.wallpaperama.com/forums/howto-fix-fatal-error-cannot-use-object-of-type-stdclass-as-array-in-php-t1735.html