From f90c6b5bb98873c34e19e00e4f1053574eed641e Mon Sep 17 00:00:00 2001 From: csisoap <33269526+csisoap@users.noreply.github.com> Date: Sat, 10 Oct 2020 01:33:54 +0700 Subject: [PATCH] [NasaApodBridge] Fix broken image link (#1778) --- bridges/NasaApodBridge.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index e5893dbc..cf633415 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -12,8 +12,6 @@ class NasaApodBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI . 'archivepix.html') or returnServerError('Error while downloading the website content'); - $list = explode('
', $html->find('b', 0)->innertext); - // Start at 1 to skip the "APOD Full Archive" on top of the page for($i = 1; $i < 4; $i++) { $item = array(); @@ -26,9 +24,14 @@ class NasaApodBridge extends BridgeAbstract { $picture_html_string = $picture_html->innertext; //Extract image and explanation - $media = $picture_html->find('p', 1)->innertext; - $media = strstr($media, '
'); - $media = preg_replace('/
/', '', $media, 1); + $image_wrapper = $picture_html->find('a',1); + $image_path = $image_wrapper->href; + $img_placeholder = $image_wrapper->find('img', 0); + $img_alt = $img_placeholder->alt; + $img_style = $img_placeholder->style; + $image_uri = self::URI . $image_path; + $new_img_placeholder = "\"$img_alt\""; + $media = "$new_img_placeholder"; $explanation = $picture_html->find('p', 2)->innertext; //Extract date from the picture page