示例#1
0
文件: Parser.php 项目: braseidon/mole
 /**
  * Process the returned HTML with our parsers
  *
  * @param  Request     $request
  * @param  RollingCurl $rolling_curl
  * @return void
  */
 public function parseHtml(Request $request)
 {
     $html = $request->getResponseText();
     $url = $request->getUrl();
     $httpCode = array_get($request->getResponseInfo(), 'http_code', false);
     // For checking if $rollingCurl is keeping the same instance
     // $rollingCurl->log('<span style="color:#ccc;"><strong>Code:</strong> ' . $httpCode . ' <strong>URL:</strong> #' . $rollingCurl->countCompleted() . ' - ' . $request->getUrl() . '</span><br />');
     $newLinks = [];
     if ($httpCode >= 200 and $httpCode < 400 and !empty($html)) {
         // Parse - Links
         $newLinks = $this->parseNewLinks($html);
         // $this->parseNewLinks($html);
         // Parse - Emails
         $this->getEmails()->run($html);
         // Garbage collect
         unset($html, $url, $httpCode);
         // if (is_array($newLinks) && count($newLinks) > 0) {
         //     // dd($newLinks);
         //     $rollingCurl->addRequests($newLinks);
         // }
     }
     return $newLinks;
 }