Example #1
0
 /**
  * Returns Proxy object
  * @param ProxyGenerator $generator
  *
  * @return ProxyInterface[]
  * @throws \Exception
  */
 public function getProxy(ProxyGenerator $generator)
 {
     if (!is_a($generator, ProxyGenerator::className())) {
         throw new \Exception("Provided generator is not of type ProxyGenerator");
     }
     return $generator->generateProxy();
 }
Example #2
0
 public function generateProxy()
 {
     $crawler = new GeneralCrawler(self::URL, null, true);
     $extractor = new MultipleRowExtractor($crawler, __DIR__ . self::RULE_FILE);
     $results = $extractor->extract();
     $proxies = array();
     foreach ($results as $result) {
         $result['working'] = parent::checkProxy($result['ip'], $result['port']);
         if (!$result['working']) {
             continue;
         }
         $proxies[] = $this->getProxy($result);
     }
     return $proxies;
 }