跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 问个关于php curl的技术问题,望大佬能点拨一二
未分類
25 9 月 2021

问个关于php curl的技术问题,望大佬能点拨一二

cnzmz 大佬有话说 :

问个关于php curl的技术问题,望大佬能点拨一二

本帖最后由 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);

loveqianool 大佬有话说 :

他要饼**就给他个饼干呀

hihelllo 大佬有话说 :

让curl提交携带cookies
–cookie
cookies可用curl获取也可用浏览器提取写入变量。

榆木 大佬有话说 :

也有可能网站是动态渲染的。你

longkulo 大佬有话说 :

最后一行代码,你复制一遍试试?
让它执行两次.:lol

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具