去下载一个httpClient类,http://scripts.incutio.com/httpclient/index.php

解决方案 »

  1.   

    啊啊啊,网页打不开……
    这个类可以mail给我么??[email protected]谢谢老……
    php的curl看了些,,没有实践的经验,,写不出来……
      

  2.   

    这个类,好像,,对https的不管用,我本机上面的https的页面都get不到,但是可以get外面的http的页面
      

  3.   

    socket的snoopy对吧??我搜一下……
      

  4.   

    又找不到snoopy的使用文档……我晕。。
      

  5.   

    不行不行,,https还是不行。。我……我郁闷…………
      

  6.   

    https需要你自己修改一下才可以支持,并确定要打开php open_ssl的支持
    修改php.ini
    extension = open_ssl.dll修改httpClient类
    1处 => 构造函数   修改如下:
        function HttpClient($host, $port=80, $ssl=false) {
            $this->host = $host;
            $this->port = $port;
            $this->ssl  = $ssl;
        }2处 => doRequest函数 修改如下
    function doRequest(){  
    $host = $this->ssl ? "ssl://" . $this->host : $this->host;   <= 增加此行在调用类的时候,如果使用https要指定端口,一般为443
    $http = new HttpClient( "www.test.com", 443, true );
      

  7.   

    Gdj(陈水.智商只有129.非卖品) ( ) 信誉:100  2006-05-20 10:48:00  得分: 0  
     
     
       什么类这么厉害能识别出验证码?
      
     
    =-------------
    不需要识别,但是需要把验证码也显示出来手动填写:)
    ---------------------
    谢谢ice_berg16(寻梦的稻草人),我再看看程序:)
      

  8.   

    偶改的一个类,原来只支持GET (http/https)<?php
    $data = "login=" . urlencode("abc") . "&password=" . urlencode("123456")."&checkpass=".urlencode("Login!");
    $r=new HTTPRequest("https://localhost/csdn/pass.php","POST",$data);
    /**
     *
     * 支持GET | POST 
     *  HTTP | HTTPS
     */
    class HTTPRequest
    {
     var $mArray=array("GET","POST");
       var $_fp;        // HTTP socket
       var $_url;        // full URL
       var $_host;        // HTTP host
       var $_protocol;    // protocol (HTTP/HTTPS)
       var $_uri;        // request URI
       var $_method;        // method
       var $_query;        // query   
       var $_port;        // port
       
       // scan url
       function _scan_url()
       {
           $req = $this->_url;
           
           $pos = strpos($req, '://');
           $this->_protocol = strtolower(substr($req, 0, $pos));
           
           $req = substr($req, $pos+3);
           $pos = strpos($req, '/');
           if($pos === false)
               $pos = strlen($req);
           $host = substr($req, 0, $pos);
           
           if(strpos($host, ':') !== false)
           {
               list($this->_host, $this->_port) = explode(':', $host);
           }
           else 
           {
               $this->_host = $host;
               $this->_port = ($this->_protocol == 'https') ? 443 : 80;
           }
           
           $this->_uri = substr($req, $pos);
           if($this->_uri == '')
               $this->_uri = '/';
       }
       
       // constructor
       function HTTPRequest($url,$method="GET",$query="")
       {
           $this->_method=(in_array($method,$this->mArray))?$method:"GET";
           $this->_url = $url;
           $this->_query = $query;
           $this->_scan_url();
       }
       
       // download URL to string
       function DownloadToString()
       {
           $crlf = "\r\n";
           
           // generate request
           $req = $this->_method ." ". $this->_uri . ' HTTP/1.0' . $crlf
               .    'Host: ' . $this->_host . $crlf.(($this->_method=="POST")?("Content-type: application/x-www-form-urlencoded\r\nUser-Agent: Mozilla 4.0\r\nContent-length: ".strlen($this->_query)."\r\nAccept: */*\r\n\r\n$this->_query".$crlf.$crlf):$crlf);
           // fetch
           $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port, $errno, $errstr, 30);
           fwrite($this->_fp, $req);
           while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
               $response .= fread($this->_fp, 1024);
           fclose($this->_fp);
           
           // split header and body
           $pos = strpos($response, $crlf . $crlf);
           if($pos === false)
               return($response);
           $header = substr($response, 0, $pos);
           $body = substr($response, $pos + 2 * strlen($crlf));
           
           // parse headers
           $headers = array();
           $lines = explode($crlf, $header);
           foreach($lines as $line)
               if(($pos = strpos($line, ':')) !== false)
                   $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
           
           // redirection?
           if(isset($headers['location']))
           {
               $http = new HTTPRequest($headers['location']);
               return($http->DownloadToString($http));
           }
           else 
           {
               return($body);
           }
       }
    }
    ?> 
      

  9.   

    谢谢回复了但是好像还是没有搞定用curl的函数倒是可以,,不过功能太简单,想用snoopy的类或者httpclient类需要snoopy支持https,里面的curl_path文档说的是需要修改成自己的curl安装的目录。curl我只是在php的extension里面加载了php_curl.dll不知道curl的安装是怎样的???把curl_path改成php的这个ext目录也不行,,问下curl安装还需要安装啥子软件么??
      

  10.   

    Q: Why can't I fetch https pages?
    A: Using Snoopy to fetch an https page requires curl. Check if curl is installed on your host. If curl is installed, it may be located in a different place than the default. By default Snoopy looks for curl in /usr/local/bin/curl. Run 'which curl' and find out your location. If it differs from the default, then you'll need to set the $snoopy->curl_path variable to the location of your curl installation. Here's an example of the code :
    include "Snoopy.class.php";
    $snoopy = new Snoopy;
    $snoopy->curl_path="/usr/bin/curl";这个是snoopy类得支持https得文档,,不懂啥子意思。。类里面要用到$snoopy->curl_path是否可以执行,,如果是文件名肯定不可以执行撒
      

  11.   

    但是好像还是没有搞定
    我用这个修改的类取https的内容都没有问题。
      

  12.   

    ice_berg16(寻梦的稻草人) ( ) 信誉:125  2006-05-22 09:17:00  得分: 0  
     
     
       但是好像还是没有搞定
    我用这个修改的类取https的内容都没有问题。
    ------------
    嘿嘿,,你修改那儿确实有问题。。
    应该是:$this->host = $this->ssl ? "ssl://" . $this->host : $this->host;
    而不是$host = $this->ssl ? "ssl://" . $this->host : $this->host;httpclient类依着顺序调试老一下,眼睛都看花了现在好了,谢谢哈:) scsjs(闪电回归) ( ) 信誉:100  2006-05-22 09:29:00  得分: 0  
     
     
       :) 二個稻草人 ,,,,, :)
      
     ------------
    他寻梦,我已经寻到了。。;)
      

  13.   

    哦,是我少贴了代码,不好意思,我后面那句也改了if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
    =>
    if (!$fp = @fsockopen($host, $this->port, $errno, $errstr, $this->timeout)) {不过你改成那样下面就不用改了,一样的
      

  14.   

    re guestdaocao(稻草人)
     ------------
    他寻梦,我已经寻到了。。;)
    ------------------------------
    樓主真的找到了呀!!告訴我,在哪裏的說,偶也想要一個...
      

  15.   

    只能用AJAX,用JS实现,不过验证码都要手动填写