【引用】CURL模似登陆SSL问题

来源: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:\phpcode\www\cookie.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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值