21,886
社区成员
发帖
与我相关
我的任务
分享
function open_https_url($url,$postfields = '',$cookie_file = '',$referer = ''){
$curl = curl_init();
$options = array(
CURLOPT_URL => $url, // 地址
CURLOPT_HEADER => 0,
CURLOPT_NOBODY => 0,
CURLOPT_PORT => 443,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1, // 使用自动跳转
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_REFERER => $referer
);
if($postfields)
{
$options[CURLOPT_POST] = 1;
$options[CURLOPT_POSTFIELDS] = $postfields;
}
if($cookie_file)
{
$options[CURLOPT_COOKIEJAR] = $cookie_file; // 存放Cookie信息的文件名称
$options[CURLOPT_COOKIEFILE] = $cookie_file; // 读取上面所储存的Cookie信息
}
curl_setopt_array($curl, $options);
$result = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
// 如果出错
return $error ? $error : $result;
}
set_time_limit(0);
// 设置Cookie文件保存路径及文件名
$cookie_file = dirname(__FILE__)."/cookie_".md5(basename(__FILE__)).".txt";
$url = 'https://member.mycard520.com.tw/Login/MemberLogin.aspx?ReturnUrl=%2fDefault.aspx';
$postfields = array();
echo open_https_url($url,$postfields,$cookie_file,'');
$url = 'https://www.mycard520.com.tw/mycardstore/store.aspx';
echo open_https_url($url);
header('Content-Type:text/html;charset=utf-8');
$curl=curl_init('https://member.mycard520.com.tw/Login/MemberLogin.aspx?ReturnUrl=%2fDefault.aspx');
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_MAXREDIRS, 1000);
$html=curl_exec($curl);
var_dump($html);