[NasaApodBridge] Fix broken image link (#1778)

This commit is contained in:
csisoap 2020-10-10 01:33:54 +07:00 committed by GitHub
parent ff98efe8dc
commit f90c6b5bb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,8 +12,6 @@ class NasaApodBridge extends BridgeAbstract {
$html = getSimpleHTMLDOM(self::URI . 'archivepix.html') $html = getSimpleHTMLDOM(self::URI . 'archivepix.html')
or returnServerError('Error while downloading the website content'); or returnServerError('Error while downloading the website content');
$list = explode('<br>', $html->find('b', 0)->innertext);
// Start at 1 to skip the "APOD Full Archive" on top of the page // Start at 1 to skip the "APOD Full Archive" on top of the page
for($i = 1; $i < 4; $i++) { for($i = 1; $i < 4; $i++) {
$item = array(); $item = array();
@ -26,9 +24,14 @@ class NasaApodBridge extends BridgeAbstract {
$picture_html_string = $picture_html->innertext; $picture_html_string = $picture_html->innertext;
//Extract image and explanation //Extract image and explanation
$media = $picture_html->find('p', 1)->innertext; $image_wrapper = $picture_html->find('a',1);
$media = strstr($media, '<br>'); $image_path = $image_wrapper->href;
$media = preg_replace('/<br>/', '', $media, 1); $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 src=\"$image_uri\" alt=\"$img_alt\" style=\"$img_style\">";
$media = "<a href=\"$image_uri\">$new_img_placeholder</a>";
$explanation = $picture_html->find('p', 2)->innertext; $explanation = $picture_html->find('p', 2)->innertext;
//Extract date from the picture page //Extract date from the picture page