af_comics filters: don't try to load empty html

This commit is contained in:
Andrew Dolgov 2021-03-05 10:07:34 +03:00
parent bc2953b5e7
commit c8883d3440
10 changed files with 16 additions and 10 deletions

View File

@ -17,7 +17,7 @@ class Af_Comics_Cad extends Af_ComicFilter {
if (!$res && UrlHelper::$fetch_last_error_content)
$res = UrlHelper::$fetch_last_error_content;
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0);

View File

@ -17,7 +17,7 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//div[@class="comic"]')->item(0);

View File

@ -23,7 +23,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//div[@id="comic"]')->item(0);

View File

@ -18,7 +18,7 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//div[@class="comic"]')->item(0);

View File

@ -19,7 +19,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
// Get the image container

View File

@ -25,7 +25,9 @@ class Af_Comics_Pa extends Af_ComicFilter {
if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) {
$doc = new DOMDocument();
if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$res = UrlHelper::fetch($article["link"]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//div[@class="post"])');

View File

@ -14,7 +14,7 @@ class Af_Comics_Pvp extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//section[@class="comic-art"]')->item(0);

View File

@ -16,7 +16,9 @@ class Af_Comics_Tfd extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$res = UrlHelper::fetch($article["link"]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0);

View File

@ -11,7 +11,9 @@ class Af_Comics_Twp extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
$res = UrlHelper::fetch($article["link"]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXpath($doc);
$basenode = $xpath->query("//td/center/img")->item(0);

View File

@ -17,7 +17,7 @@ class Af_Comics_Whomp extends Af_ComicFilter {
$doc = new DOMDocument();
if (@$doc->loadHTML($res)) {
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//img[@id="cc-comic"]')->item(0);