Codeigniter 中使用PHP爬虫设置
1. 在Codeigniter中添加 php simple html dom 核心文件
2. 在application、helper中加入该文件
3. 在PHP文件中添加如下代码
public function __construct(){ parent::__construct(); $this->load->helper('simple_html_dom'); }
4. 使用简单实例:
$url = "https://www.ebay.com/deals/trending/all"; $html = file_get_html($url); //找到所有链接 foreach($html->find('a') as $element) echo $element->href . '<br>';

浙公网安备 33010602011771号