~josealberto4444/apodnasabot

e500f6f6e608f66a73a2e1a4c925ad0042a16474 — José Alberto Orejuela García 2 years ago dcc0059
Fix style
1 files changed, 3 insertions(+), 3 deletions(-)

M api.py
M api.py => api.py +3 -3
@@ 27,7 27,7 @@ def read_api_key():
def ask_api(api_key, date):
    baseurl = 'https://api.nasa.gov/planetary/apod'
    payload = {'api_key': api_key, 'date': date}
    r = requests.get(baseurl, params = payload)
    r = requests.get(baseurl, params=payload)
    return r.json()

def save_json(filename, api_response):


@@ 61,11 61,11 @@ def get_userpage(date):
    shortdate = intl_to_short(date)
    url = 'https://apod.nasa.gov/apod/ap' + shortdate + '.html'
    payload = {}
    r = requests.get(url, params = payload)
    r = requests.get(url, params=payload)
    return r.text

def scrap_description(pagesource):
    re_description = re.compile("Explanation: </b> (.*?)<p>", flags = re.DOTALL)
    re_description = re.compile("Explanation: </b> (.*?)<p>", flags=re.DOTALL)
    description = re_description.search(pagesource).groups()[0]
    description = description.replace('\n>', '>')
    description = description.replace('\n', ' ')