From 5966cc0a9c18dbbbc8b7cc90e73582000d02a437 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sat, 3 Apr 2021 18:31:49 +0000 Subject: [PATCH] [TheFarSideBridge] Add bridge (#1484) --- bridges/TheFarSideBridge.php | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bridges/TheFarSideBridge.php diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php new file mode 100644 index 00000000..6b598ede --- /dev/null +++ b/bridges/TheFarSideBridge.php @@ -0,0 +1,51 @@ +find('div.tfs-page-container__cows', 0); + + $item = array(); + $item['uri'] = $html->find('meta[property="og:url"]', 0)->content; + $item['title'] = $div->find('h3', 0)->innertext; + $item['timestamp'] = $div->find('h3', 0)->innertext; + $item['content'] = ''; + + foreach($div->find('div.card-body') as $index => $card) { + $image = $card->find('img', 0); + $imageUrl = $image->attr['data-src']; + + // Images are downloaded to bypass the hotlink protection. + $image = getContents($imageUrl, array('Referer: ' . self::URI)) + or returnServerError('Could not request: ' . $imageUrl); + + // Encode image as base64 + $imageBase64 = base64_encode($image); + + $caption = ''; + + if ($card->find('figcaption', 0)) { + $caption = $card->find('figcaption', 0)->innertext; + } + + $item['content'] .= << + +
{$caption}
+ +
+EOD; + } + + $this->items[] = $item; + } +}