removido retentativas

This commit is contained in:
Renan Bernordi 2024-12-05 13:12:49 -03:00
parent 76dcdaef75
commit 6897218bc0

View file

@ -24,11 +24,6 @@ class URLAnalyzer
*/
private $userAgents;
/**
* @var int Número máximo de tentativas para obter conteúdo
*/
private $maxAttempts;
/**
* @var array Lista de servidores DNS para resolução
*/
@ -51,7 +46,6 @@ class URLAnalyzer
public function __construct()
{
$this->userAgents = USER_AGENTS;
$this->maxAttempts = MAX_ATTEMPTS;
$this->dnsServers = explode(',', DNS_SERVERS);
$this->rules = new Rules();
$this->cache = new Cache();
@ -166,7 +160,6 @@ class URLAnalyzer
$userAgentKeys = array_keys($this->userAgents);
$totalUserAgents = count($userAgentKeys);
while ($attempts < $this->maxAttempts) {
try {
// Seleciona um user agent de forma rotativa
$currentUserAgentKey = $userAgentKeys[$attempts % $totalUserAgents];
@ -178,10 +171,6 @@ class URLAnalyzer
$errors[] = $e->getMessage();
}
$attempts++;
usleep(500000); // 0.5 segundo de espera entre tentativas
}
// Se todas as tentativas falharem, tenta buscar do Wayback Machine
try {
$content = $this->fetchFromWaybackMachine($url);
@ -192,7 +181,7 @@ class URLAnalyzer
$errors[] = "Wayback Machine: " . $e->getMessage();
}
throw new Exception("Falha ao obter conteúdo após {$this->maxAttempts} tentativas e Wayback Machine. Erros: " . implode(', ', $errors));
throw new Exception("Falha ao obter conteúdo. Erros: " . implode(', ', $errors));
}
/**