~josealberto4444/apodnasabot

262d543724029575738bd87e6f3e5963a5d772f6 — José Alberto Orejuela García 4 months ago 822a07d master 0.2.1
Fix a new error in scrapping explanation
1 files changed, 2 insertions(+), 1 deletions(-)

M api.py
M api.py => api.py +2 -1
@@ 1,4 1,4 @@
# Copyright © 2019 José Alberto Orejuela García (josealberto4444)
# Copyright © 2019-2020 José Alberto Orejuela García (josealberto4444)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by


@@ 90,6 90,7 @@ class Apod:
        explanation = explanation.replace('\n>', '>') # Fix split HTML tags.
        explanation = explanation.replace('<a/>', '</a>') # Fix typos (they seem to write the HTML by hand, yes).
        explanation = explanation.replace('\n', ' ') # Delete all newlines.
        explanation = explanation.replace('<br>', ' ') # Delete all HTML newlines.
        explanation = re.sub('\s+', ' ', explanation).strip() # Substitute repeated spaces and strips the ones at the beginning and the end of the string.
        explanation = re.sub(r'<a([^>]*)href=["\'](?!http)([^"\']*)["\']([^>]*)>', r'<a\1href="https://apod.nasa.gov/apod/\2"\3>', explanation) # Change relative paths to absolute.
        return explanation