Skip to content

Commit

Permalink
removido logs e liberado selenium como ultimo fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
altendorfme committed Dec 24, 2024
1 parent 775b6bd commit c9e59df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions TESTED_URLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ https://oantagonista.com.br/brasil/lewandowski-insiste-na-pec-da-seguranca/
https://jornaldebrasilia.com.br/noticias/politica-e-poder/lula-aguarda-pt-para-troca-em-pastas-chefiadas-por-petistas-em-reforma-ministerial/
https://opopular.com.br/cidades/ex-secretario-de-saude-de-goiania-deixa-hospital-e-volta-para-a-cadeia-1.3207162
https://www.cartacapital.com.br/politica/surpresa-natalina/
https://seucreditodigital.com.br/123milhas-devera-apresentar-plano-de-recuperacao-ainda-este-mes/
https://www.matinaljornalismo.com.br/matinal/reportagem-matinal/vazao-guaiba-porto-alegre/

## Internacional
https://www.nytimes.com/2024/11/20/us/politics/matt-gaetz-venmo-payments-sex.html
Expand Down
1 change: 1 addition & 0 deletions app/data/blocked_domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'utppublishing.com',
'chronicle.com',
'nexojornal.com',
'nexojornal.com.br',
'lesoir.be',
'weeklytimesnow.com.au',
'barrons.com',
Expand Down
17 changes: 14 additions & 3 deletions app/inc/URLAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public function analyze($url)
$host = preg_replace('/^www\./', '', $host);

if (in_array($host, BLOCKED_DOMAINS)) {
Logger::getInstance()->log($cleanUrl, 'BLOCKED_DOMAIN');
throw new Exception('Este domínio está bloqueado para extração.');
}

Expand Down Expand Up @@ -153,7 +152,7 @@ public function analyze($url)
return $processedContent;
}
} catch (Exception $e) {
Logger::getInstance()->log($cleanUrl, 'DIRECT_FETCH_ERROR', $e->getMessage());
error_log("DIRECT_FETCH_ERROR: " . $e->getMessage());
}

// 6. Tenta buscar do Wayback Machine como fallback
Expand All @@ -165,7 +164,19 @@ public function analyze($url)
return $processedContent;
}
} catch (Exception $e) {
Logger::getInstance()->log($cleanUrl, 'WAYBACK_FETCH_ERROR', $e->getMessage());
error_log("WAYBACK_FETCH_ERROR: " . $e->getMessage());
}

// 7. Tenta buscar com Selenium como fallback
try {
$content = $this->fetchFromSelenium($cleanUrl, 'firefox');
if (!empty($content)) {
$processedContent = $this->processContent($content, $host, $cleanUrl);
$this->cache->set($cleanUrl, $processedContent);
return $processedContent;
}
} catch (Exception $e) {
error_log("SELENIUM_ERROR: " . $e->getMessage());
}

Logger::getInstance()->log($cleanUrl, 'GENERAL_FETCH_ERROR');
Expand Down

0 comments on commit c9e59df

Please sign in to comment.