Collect the title and link of the Baidu search result list.
$data = QueryList::get('https://www.baidu.com/s?wd= QueryList') // Set collection rules ->rules([ ‘Title’=>array(‘h3’,‘text’), ‘Link’=>array(‘h3>a’,‘href’) ]) ->queryData(); print_r($data);
Collection results:
Array ( [0] => Array ( [title] => QueryList|An extremely powerful PHP collection tool based on phpQuery [link] => http://www.baidu.com/link?url=GU_YbDT2IHk4ns1tjG2I8_vjmH0SCJEAPuuZN ) [1] => Array ( [title] => PHP uses QueryList to grab web content-wb145230-博客园 [link] => http://www.baidu.com/link?url=zn0DXBnrvIF2ibRVW34KcRVFG1_bCdZvqvwIhUqiXaS ) [2] => Array ( [title] => Introduction-QueryList guide document [link] => http://www.baidu.com/link?url=pSypvMovqS4v2sWeQo5fDBJ4EoYhXYi0Lxx ) //... )
Marble component
$data = QueryList::get('https: //www.baidu.com/s?wd=QueryList') // Set collection rules ->rules([ ‘Title’=>array(‘h3’,‘text’), ‘Link’=>array(‘h3>a’,‘href’) ]) ->queryData(); print_r($data);
Array ( [0] => Array ( [title] => QueryList|An extremely powerful PHP collection tool based on phpQuery [link] => http://www.baidu.com/link?url=GU_YbDT2IHk4ns1tjG2I8_vjmH0SCJEAPuuZN ) [1] => Array ( [title] => PHP uses QueryList to grab web content-wb145230-博客园 [link] => http://www.baidu.com/link?url=zn0DXBnrvIF2ibRVW34KcRVFG1_bCdZvqvwIhUqiXaS ) [2] => Array ( [title] => Introduction-QueryList guide document [link] => http://www.baidu.com/link?url=pSypvMovqS4v2sWeQo5fDBJ4EoYhXYi0Lxx ) //... )