本帖最后由 cnzmz 于 2021-9-24 20:20 编辑
在php里面,通过curl提交get请求或者post请求的时候,请求的网站返回提示“In order to use this proxy server, you will need to enable cookies in your web browser.”
提示让我允许浏览器的cookie功能,不过这个本来就是在服务器上通过curl来模拟浏览器的请求的,是不是应该添加个什么参数进去呢
请问是否在curl参数里面能设置一下解决这个问题呢?我的curl参数设置如下
- $ch = curl_init();
- if($proxy){
- curl_setopt ($ch, CURLOPT_PROXY, $proxy);
- }
- curl_setopt($ch, CURLOPT_URL, $url);
- //The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75');
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/cache/".$cookie_file);
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/cache/".$cookie_file);
- $output = curl_exec($ch);
复制代码 |