コード例 #1
0
ファイル: ProxyUpdate.php プロジェクト: bpteam/php-proxy-list
 protected function checkProxyArrayToSite($arrayProxy, $url, $checkWord, $chunk = 100)
 {
     if (!is_array($arrayProxy)) {
         return [];
     }
     $goodProxy = [];
     $this->loader->setCountStream(1);
     $this->loader->setTypeContent('text');
     $this->loader->setDefaultOption(CURLOPT_POST, false);
     $this->loader->setDefaultOption(CURLOPT_TIMEOUT, 30);
     $this->loader->setCheckAnswer(false);
     foreach (array_chunk($arrayProxy, $chunk) as $challenger) {
         $this->loader->setCountCurl(count($challenger));
         $descriptorArray =& $this->loader->getDescriptorArray();
         $urlList = [];
         foreach ($descriptorArray as $key => &$descriptor) {
             $this->loader->setOption($descriptor, CURLOPT_PROXY, $challenger[$key]['proxy']);
             $urlList[] = $url;
         }
         foreach ($this->loader->load($urlList) as $key => $answer) {
             $testCount = 0;
             $countGood = 0;
             foreach ($checkWord as $valueCheckWord) {
                 $testCount++;
                 if (preg_match($valueCheckWord, $answer)) {
                     $countGood++;
                 }
             }
             if ($countGood == $testCount) {
                 $goodProxy[] = $challenger[$key];
             }
         }
     }
     return count($goodProxy) ? $goodProxy : [];
 }