mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-10 00:48:48 +00:00
[ScribbleHubBridge] Add CloudFlare error handling (#3361)
* [ScribbleHubBridge] Set html defaultLinkTo * [ScrubbleHubBridge] Add CloudFlare error handling
This commit is contained in:
parent
c6c4b3a24f
commit
dc4134ed1d
@ -54,7 +54,20 @@ class ScribbleHubBridge extends FeedExpander
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item_html = getSimpleHTMLDOMCached($item['uri'])) {
|
$item['comments'] = $item['uri'] . '#comments';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$item_html = getSimpleHTMLDOMCached($item['uri']);
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
// 403 Forbidden, This means we got anti-bot response
|
||||||
|
if ($e->getCode() === 403) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item_html = defaultLinkTo($item_html, self::URI);
|
||||||
|
|
||||||
//Retrieve full description from page contents
|
//Retrieve full description from page contents
|
||||||
$item['content'] = $item_html->find('#chp_raw', 0);
|
$item['content'] = $item_html->find('#chp_raw', 0);
|
||||||
|
|
||||||
@ -70,7 +83,6 @@ class ScribbleHubBridge extends FeedExpander
|
|||||||
//Generate UID
|
//Generate UID
|
||||||
$item_pid = $item_html->find('#mypostid', 0)->value;
|
$item_pid = $item_html->find('#mypostid', 0)->value;
|
||||||
$item['uid'] = $item_sid . "/$item_pid";
|
$item['uid'] = $item_sid . "/$item_pid";
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
@ -80,11 +92,27 @@ class ScribbleHubBridge extends FeedExpander
|
|||||||
$name = parent::getName() . " $this->queriedContext";
|
$name = parent::getName() . " $this->queriedContext";
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
case 'Author':
|
case 'Author':
|
||||||
|
try {
|
||||||
$page = getSimpleHTMLDOMCached(self::URI . 'profile/' . $this->getInput('uid'));
|
$page = getSimpleHTMLDOMCached(self::URI . 'profile/' . $this->getInput('uid'));
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
// 403 Forbidden, This means we got anti-bot response
|
||||||
|
if ($e->getCode() === 403) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
$title = html_entity_decode($page->find('.p_m_username.fp_authorname', 0)->plaintext);
|
$title = html_entity_decode($page->find('.p_m_username.fp_authorname', 0)->plaintext);
|
||||||
break;
|
break;
|
||||||
case 'Series':
|
case 'Series':
|
||||||
|
try {
|
||||||
$page = getSimpleHTMLDOMCached(self::URI . 'series/' . $this->getInput('sid') . '/a');
|
$page = getSimpleHTMLDOMCached(self::URI . 'series/' . $this->getInput('sid') . '/a');
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
// 403 Forbidden, This means we got anti-bot response
|
||||||
|
if ($e->getCode() === 403) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
$title = html_entity_decode($page->find('.fic_title', 0)->plaintext);
|
$title = html_entity_decode($page->find('.fic_title', 0)->plaintext);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user