duangou6446 2018-06-18 20:47
浏览 15

如何在get请求中发送下一个cookie?

I receive 503 error, but if i send it from inspect element its fine.

The code worked for me before, but in the last few hours the specific website added cf_clearance and I need to add it to the request as well

How do i send the both cookies?

$opts = array(
'http'=>array(
'method'=>"GET",
'proxy'=>"",
'header'=> "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0
" .
           "Cookie: cf_clearance=3de18fcd39d55ce82d9db-1529352303-31536000; PHPSESSID=oahfun4m7vi3edd71
"
));
$context = stream_context_create($opts);
$url = "http://website.com";

$data = file_get_contents($url, false, $context);

echo $data;
  • 写回答

1条回答 默认 最新

  • dsfsfsfsfs55656 2018-06-18 20:53
    关注

    There's a pretty good example in the documentation.

    $opts = array(
      'http'=>array(
        'method'=>"GET",
        'header'=>"Accept-language: en
    " .
                  "Cookie: foo=bar
    "
      )
    );
    

    Add line breaks and concatenate. Your example right now should be resulting in a syntax error because you are not concatenating the two strings.

    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序