记录一次PHP curl带cookie参请求

<?php
 
header("Content-type:text/html;Charset=utf8");

$ch =curl_init();
curl_setopt($ch,CURLOPT_URL,'https://www.xxx.com/index.php');

$header = array();

//curl_setopt($ch,CURLOPT_POST,true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_COOKIE,'a=123; b=321;');

$content = curl_exec($ch);

echo "<pre>";print_r(curl_error($ch));echo "</pre>";
echo "<pre>";print_r(curl_getinfo($ch));echo "</pre>";
echo "<pre>";print_r($header);echo "</pre>";
echo "</br>",$content;

 

上一篇:Python机器学习预测苹果酸甜度


下一篇:C# 元组