有一网站:
https://A.com.cn/XXX访问后提示:
这个用户名和密码都是知道的,点击可以正常登陆~~~但如果用curl应该怎么进行模拟登陆??有没有成功的案例?

解决方案 »

  1.   

    有个例子,但我不曾验证过你可以验证验证
    $ch = curl_init("http://localhost/test.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, 'myuser:mypwd');
    // sending username and pwd.
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,
    false);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION,
    true);
    curl_setopt($curl, CURLOPT_USERAGENT, 'Sample Code');
    curl_setopt($curl, CURLINFO_HEADER_OUT, true);
    $output = curl_exec($ch);
    print_r(curl_getinfo($ch));
    curl_close($ch);
    echo '<br><br>';
    echo $output;
      

  2.   

    没有通过,还是提示401
    HTTP Status 401 -type Status reportmessagedescription This request requires HTTP authentication ().Apache Tomcat/5.5.28-1
      

  3.   

    <?php
    $curl = curl_init(); 
    curl_setopt($curl, CURLOPT_URL, 'http://www.360buy.com/product/549427.html'); 
    curl_setopt($curl, CURLOPT_REFERER, 'http://www.360buy.com'); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
    $result = curl_exec($curl); 
    curl_close($curl); 
    print_r($result);
    ?>给你个例子。参考下
      

  4.   

    这是对普通的url,对这个https成功不了~~
      

  5.   

    网上找到一个:
    http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/现在错误不是401了,但还是提示验证不通过,大家还有什么思路吗? 
      

  6.   

    通过header组合需要的加密串 , 可以请求 , 也证书之类没关系公司内其它人解决的 , 有空再研究下他的代码~~