/** * Logging stuff * * @param Request $request * @param integer $httpCode * @return void */ private function logCallback(Request $request, $httpCode) { $this->log('#' . $this->countCompleted()); $this->log('<strong>Code:</strong> ' . $httpCode); $this->log('<strong>Pending:</strong> ' . $this->countPending()); $this->log('<strong>Active:</strong> ' . $this->countActive()); $this->log('<strong>Memory:</strong> ' . formatSizeUnits($this->logMemoryUsage())); $this->log('<strong>AVG:</strong> ' . $this->logAvgMemoryUsage()); $this->log('<strong>URL:</strong> ' . $request->getUrl()); $this->log('<br />'); }
/** * 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; }