maroph

getAPOD.py

Nov 11th, 2019
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #
  3. # Get data of a NASA APOD (Astronomy Picture of the Day)
  4. #
  5. # For more details see:
  6. # NASA APIs: https://api.nasa.gov/
  7. #
  8. import requests
  9. #
  10. proxies = {
  11.   "http": None,
  12.   "https": None,
  13. }
  14. #
  15. headers = {"Content-Type" : "application/json;charset=utf-8"}
  16. #
  17. res = requests.get('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=2019-11-11', proxies=proxies,headers=headers)
  18. if res != None:
  19.     if res.status_code == 200:
  20.         print(res.text)
  21.     else:
  22.         print('HTTP status :', res.status_code)
  23.         print('encoding    :', res.encoding)
  24.         print(res.text)
Advertisement
Add Comment
Please, Sign In to add comment