mirror of
https://github.com/manualdousuario/marreta.git
synced 2025-09-02 10:42:06 +00:00
removido retentativas
This commit is contained in:
parent
76dcdaef75
commit
6897218bc0
1 changed files with 9 additions and 20 deletions
|
@ -24,11 +24,6 @@ class URLAnalyzer
|
||||||
*/
|
*/
|
||||||
private $userAgents;
|
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
|
* @var array Lista de servidores DNS para resolução
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +46,6 @@ class URLAnalyzer
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->userAgents = USER_AGENTS;
|
$this->userAgents = USER_AGENTS;
|
||||||
$this->maxAttempts = MAX_ATTEMPTS;
|
|
||||||
$this->dnsServers = explode(',', DNS_SERVERS);
|
$this->dnsServers = explode(',', DNS_SERVERS);
|
||||||
$this->rules = new Rules();
|
$this->rules = new Rules();
|
||||||
$this->cache = new Cache();
|
$this->cache = new Cache();
|
||||||
|
@ -166,7 +160,6 @@ class URLAnalyzer
|
||||||
$userAgentKeys = array_keys($this->userAgents);
|
$userAgentKeys = array_keys($this->userAgents);
|
||||||
$totalUserAgents = count($userAgentKeys);
|
$totalUserAgents = count($userAgentKeys);
|
||||||
|
|
||||||
while ($attempts < $this->maxAttempts) {
|
|
||||||
try {
|
try {
|
||||||
// Seleciona um user agent de forma rotativa
|
// Seleciona um user agent de forma rotativa
|
||||||
$currentUserAgentKey = $userAgentKeys[$attempts % $totalUserAgents];
|
$currentUserAgentKey = $userAgentKeys[$attempts % $totalUserAgents];
|
||||||
|
@ -178,10 +171,6 @@ class URLAnalyzer
|
||||||
$errors[] = $e->getMessage();
|
$errors[] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$attempts++;
|
|
||||||
usleep(500000); // 0.5 segundo de espera entre tentativas
|
|
||||||
}
|
|
||||||
|
|
||||||
// Se todas as tentativas falharem, tenta buscar do Wayback Machine
|
// Se todas as tentativas falharem, tenta buscar do Wayback Machine
|
||||||
try {
|
try {
|
||||||
$content = $this->fetchFromWaybackMachine($url);
|
$content = $this->fetchFromWaybackMachine($url);
|
||||||
|
@ -192,7 +181,7 @@ class URLAnalyzer
|
||||||
$errors[] = "Wayback Machine: " . $e->getMessage();
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue