来源:
http://www.phpx.com/happy/thread-138757-1-1.html RT,需要模似登陆
http://www.amazon.com 用CURL读https://登陆网页可以,但模似登陆就会提示[没有开启Cookies?],可以登陆
www.amazon.cn Please Enable Cookies to Continue To continue shopping at Amazon.com, please enable cookies in your Web browser. Learn more about cookies and how to enable them. Once you have enabled cookies in your browser, please click on the button below to return to the previous page. 主要代码: $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, $posturl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_COOKIEJAR, "D:*cookie.txt"); 哒人们帮忙````` //CURL SSL POST 登陆PHPX 环境php5.2.4 extension=php_curl.dll
$url = "https://www.phpx.com/logging.php?action=login";
$fields = "formhash=2d47d0be&referer=http://www.phpx.com/happy/&cookietime=315360000&username=xxxxxxxx&password=xxxxxxxxxx&loginsubmit=提 交";
$cookie_file = "D:phpcodewwwcookie.txt";
//登录
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
//写cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
//curl_setopt($ch, CURLOPT_TIMEOUT, 6);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
//echo $result;
//exit;
//登录成功操作
$url2 = "https://www.phpx.com/";
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $url2);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
//发送cookie
curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER,1);
$result2 =curl_exec($ch2);
curl_close($ch2);
echo $result2;