采集百度搜索结果列表的标题和链接。
$data = QueryList::get('https://www.baidu.com/s?wd=QueryList') // 设置采集规则 ->rules([ 'title'=>array('h3','text'), 'link'=>array('h3>a','href') ]) ->queryData(); print_r($data);
采集结果:
Array ( [0] => Array ( [title] => QueryList|基于phpQuery的无比强大的PHP采集工具 [link] => http://www.baidu.com/link?url=GU_YbDT2IHk4ns1tjG2I8_vjmH0SCJEAPuuZN ) [1] => Array ( [title] => PHP 用QueryList抓取网页内容 - wb145230 - 博客园 [link] => http://www.baidu.com/link?url=zn0DXBnrvIF2ibRVW34KcRVFG1_bCdZvqvwIhUqiXaS ) [2] => Array ( [title] => 介绍- QueryList指导文档 [link] => http://www.baidu.com/link?url=pSypvMovqS4v2sWeQo5fDBJ4EoYhXYi0Lxx ) //... )