沐风待雨 2017-02-15 16:04:42 10276次浏览 2条评论 1 2 0

https://github.com/FriendsOfPHP/Goutte
之前用下面代码采集时

namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use Goutte\Client;
/**
* 
*/
class CrawlerController extends BackendController
{
	
	public function actionIndex(){
		
		$client = new Client();
		$crawler = $client->request('GET', 'https://movie.douban.com/subject_search?search_text=

%E7%BE%8E%E5%A5%B3&cat=1002');
		$crawler->filter('li')->each(function ($node) {
    		echo '<pre>';
    		print_r($node)."<br>";
		});

	}

}

报错 cURL error 60: SSL certificate problem: unable to get local issuer certificat

最后配置了下php.ini文件
curl.cainfo = "D:\AppServ\php5\cacert.pem" //这里填写自己对应的路径
并去拷贝了下面链接的代码,自己建了个文件在上面的路径上,文件名就是cacert.pem
https://curl.haxx.se/ca/cacert.pem
重启apache,之后ok拉!

觉得很赞
您需要登录后才可以评论。登录 | 立即注册