fix(pokemonnews): throw if antibot, #3327 (#3562)

This commit is contained in:
Dag 2023-07-21 20:52:20 +02:00 committed by GitHub
parent d08b2616ef
commit 39a8346c53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -14,7 +14,10 @@ final class PokemonNewsBridge extends BridgeAbstract
// todo: parse json api instead: https://www.pokemon.com/api/1/us/news/get-news.json
$url = 'https://www.pokemon.com/us/pokemon-news';
$dom = getSimpleHTMLDOM($url);
$haystack = (string)$dom;
if (str_contains($haystack, 'Request unsuccessful. Incapsula incident')) {
throw new \Exception('Blocked by anti-bot');
}
foreach ($dom->find('.news-list ul li') as $item) {
$title = $item->find('h3', 0)->plaintext;
$description = $item->find('p.hidden-mobile', 0);