如何提高卷曲类

时间:2017-08-04 14:58:58

标签: php curl

我需要帮助来调整这个卷曲

我在sql表中有100行将调用curl类

$curl = new cURL();
$q=$sql->query("SELECT * FROM users limit $start,$limi");
while($r = $sql->fetch($q))
{

$curl->cURL($r['proxy'],$r['ip']);
$curl->proc('http://site.info/index.php',array('name'=>'username','password'=>'pass123'));
}

现在我们去卷曲课

class cURL {

    public $headers;
    public $user_agent;
    public $compression;
    public $agent;
    public $proxy;
    public $process;
    public $url;
     public $cookie;
     public $path;

    public function __construct() {

        $this->process = curl_init();

    }

    public function cURL($proxy,$agent) {
        $this->headers[] = 'Connection: Keep-Alive';
        $this->headers[] = 'charset=UTF-8';
        $this->user_agent = $agent;
        $this->compression = 'gzip,deflate';
        $this->proxy = $proxy;
        $this->agent = $agent;
        $this->path  = dirname(__FILE__) .'\temp\/';
        $this->cookie  = $this->path .'cookie.txt';
        if (!is_dir($this->path)) mkdir($this->path, 0755, true);
    }



    public function proc($url,$data=null,$nobody=false) {
        curl_setopt($this->process, CURLOPT_URL, $url);
        curl_setopt($this->process, CURLOPT_NOBODY,$nobody);
        curl_setopt($this->process, CURLOPT_HEADER,false);
        curl_setopt($this->process, CURLOPT_HTTPHEADER, $this->headers);
        curl_setopt($this->process, CURLOPT_USERAGENT, $this->user_agent);
        curl_setopt($this->process, CURLOPT_COOKIEFILE, $this->cookie);
        curl_setopt($this->process, CURLOPT_COOKIEJAR, $this->cookie);
        curl_setopt($this->process, CURLOPT_COOKIE, "cookiename=0");
        curl_setopt($this->process, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($this->process, CURLOPT_ENCODING, $this->compression);
        curl_setopt($this->process, CURLOPT_TIMEOUT, 10);
        curl_setopt($this->process, CURLOPT_PROXY, $this->proxy);
        curl_setopt($this->process, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($this->process, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
        curl_setopt($this->process, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
        curl_setopt($this->process, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($this->process, CURLOPT_FOLLOWLOCATION, 0);

        if (strpos(curl_exec($this->process),'Login') !==false){

        curl_setopt($this->process, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($this->process, CURLOPT_POST, 1);
        curl_setopt($this->process, CURLOPT_POSTFIELDS, $data);
         }


         return curl_exec($this->process);

    }

}   

问题sql while loop限制20个用户

如果cookie过期,每个调用curl函数将打开索引页面将发布登录数据并转到

  1. 打开索引并获取一些数据如果我的条件通过将调用函数$ curl-> proc()并发布新数据

  2. 打开第2页并在我的条件通过后获取一些数据将调用函数$ curl-> proc()并发布新数据

  3. 打开第3页并在我的条件通过后获取一些数据将调用函数$ curl-> proc()并发布新数据

  4. 所有这些操作将在while循环中逐个运行,这是问题编号1

    问题2 有些时候需要通过代理调用页面,我设置代理$ curl-> cURL($ r ['代理'],$ r [' ip']);

    理想的事情

    1. 在我的情况下什么是最好的curl_init或culr_multi_init
    2. 如何在最短的时间内提高课程成绩
    3. 保存对硬盘的响应并使用file_get_contents来preg_much或使用preg_much直接响应更快
    4. 有提高质量和速度的提示
    5. 谢谢

0 个答案:

没有答案