Esempio n. 1
0
 /**
  * Bites a prey to gather the needed information
  * @param WebNode $prey The current node to check
  * @param string $preyBaseUrl The base URL of the prey
  * @param string $preyBasePath The base path of the prey
  * @return null
  */
 private function bite(WebNode $prey, $preyBaseUrl, $preyBasePath)
 {
     $dom = null;
     $response = $prey->getResponse();
     $contentType = $response->getHeader('Content-Type');
     $content = $response->getContent();
     if (String::startsWith($contentType, 'text/html') && $content) {
         $dom = new Document('1.0', 'utf8');
         try {
             $result = @$dom->loadHTML($content);
             if (!$result) {
                 $error = error_get_last();
                 throw new Exception($error['message']);
             }
         } catch (Exception $exception) {
             $prey->setError($exception->getMessage());
         }
     }
     foreach ($this->bites as $bite) {
         $bite->bite($this->web, $prey, $preyBaseUrl, $preyBasePath, $dom);
     }
 }