Skip to content

Instantly share code, notes, and snippets.

@gmariette
Created April 14, 2020 08:52
Show Gist options
  • Select an option

  • Save gmariette/9678b32d2b47c0b8e3f4b5fd7a736d5b to your computer and use it in GitHub Desktop.

Select an option

Save gmariette/9678b32d2b47c0b8e3f4b5fd7a736d5b to your computer and use it in GitHub Desktop.
import requests
import json
import time
# Get the current position of the ISS
def get_iss_current_position():
r = requests.get('http://api.open-notify.org/iss-now.json')
myjson = json.loads(r.content)
if myjson["message"] == "success":
return myjson
with open('/Users/geoffrey/Desktop/iss/iss.csv', 'w') as f:
f.write('latitude,longitude,timestamp')
for i in range (0,20000):
currentPosition = get_iss_current_position()
f.write(currentPosition['iss_position']['latitude'] + ','+ currentPosition['iss_position']['longitude'] + ',' + str(currentPosition['timestamp']))
f.write("\n")
print(i)
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment