示例#1
0
 public static function getHtmlBySE($query, $se, $params = [])
 {
     if (!in_array($se, Proxy::$seAll)) {
         echo PHP_EOL . 'Search engine must be in ' . implode(', ', Proxy::$seAll);
         return false;
     }
     if (!empty(Proxy::$proxy)) {
         $proxy = current(ArrayHelper::toArray(Proxy::$proxy));
         $params = $params + ['proxy' => $proxy];
         self::$currentProxy = $proxy;
     }
     $url = isset($params['url']) ? $params['url'] : Proxy::getSEUrl($se, $query, $params);
     $html = Proxy::getHTML($url, $params);
     if (!empty(Proxy::$proxy) && !next(Proxy::$proxy)) {
         reset(Proxy::$proxy);
     }
     return $html;
 }
 /**
  * Fill blocked proxies
  * @param object $proxyModel
  * @param string $table
  */
 private function checkProxies($proxyModel)
 {
     foreach ($proxyModel as $proxyM) {
         $proxy = ['login' => $proxyM->login, 'password' => $proxyM->password, 'host' => $proxyM->host, 'port' => $proxyM->port, 'scope_id' => $proxyM->scope_id];
         $res = Proxy::getHTML('http://pdffiller.com.ua', ['proxy' => $proxy, 'getInfo' => true]);
         if (isset($res['info'])) {
             if ($res['info']['http_code'] == 0) {
                 $res = Proxy::getHTML('http://pdffiller.com', ['proxy' => $proxy, 'getInfo' => true]);
                 if (isset($res['info'])) {
                     if ($res['info']['http_code'] == 0) {
                         $this->_badProxies[] = $proxy;
                         $this->_countBadProxies++;
                         $blockedProxy = new ProxyBlocked();
                         $blockedProxy->ip = $proxyM->host;
                         //                            $blockedProxy->table = $table;
                         $blockedProxy->create_date = date('Y-m-d H:i:s');
                         $blockedProxy->save();
                     }
                 }
             }
         }
     }
 }
示例#3
0
 /**
  * @param string $query
  * @param int $start
  * @return bool
  */
 private function checkQuery($query, $start)
 {
     $result = false;
     while ($start < $this->pagesCount * $this->linksCount) {
         $proxyResult = Proxy::proxyResults($query, $start, $this->flag);
         if ($proxyResult === false && Proxy::$proxyIndex < $this->maxProxyAmount) {
             Proxy::$proxyIndex++;
             continue;
         }
         $result = !empty($proxyResult) && !empty($proxyResult['links']) && count($proxyResult['links']) >= $this->minLinksAmount;
         if (!$result) {
             var_dump($proxyResult);
             break;
         }
         $start += $this->linksCount;
     }
     return $result;
 }