fix: add workaround for NYTBridge antibot (#3022)

This commit is contained in:
Dag 2022-09-08 19:54:09 +02:00 committed by GitHub
parent 27b3d7c34e
commit 6ac347d5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -19,8 +19,15 @@ class NYTBridge extends FeedExpander
$article = '';
// $articlePage gets the entire page's contents
$articlePage = getSimpleHTMLDOM($newsItem->link);
try {
$articlePage = getSimpleHTMLDOM($newsItem->link);
} catch (HttpException $e) {
// 403 Forbidden, This means we got anti-bot response
if ($e->getCode() === 403) {
return $item;
}
throw $e;
}
// handle subtitle
$subtitle = $articlePage->find('p.css-w6ymp8', 0);
if ($subtitle != null) {