~josealberto4444/apodnasabot

812c83a7c5aadbb1bd7d976f265ab4ef2ddc6375 — José Alberto Orejuela García 2 years ago 111b5f9
Make scrapping more robust
1 files changed, 1 insertions(+), 1 deletions(-)

M api.py
M api.py => api.py +1 -1
@@ 85,7 85,7 @@ class Apod:
        return r.text

    def scrap_explanation(self, pagesource):
        re_explanation = re.compile("Explanation: </b> (.*?)<p>", flags=re.DOTALL) # Compile regex for extracting explanation.
        re_explanation = re.compile("Explanation: </b>(.*?)<p>", flags=re.DOTALL) # Compile regex for extracting explanation.
        explanation = re_explanation.search(pagesource).groups()[0] # Extract explanation.
        explanation = explanation.replace('/\n', '/') # Fix split URLs along several lines.
        explanation = explanation.replace('\n>', '>') # Fix split HTML tags.