Created
April 14, 2020 08:52
-
-
Save gmariette/9678b32d2b47c0b8e3f4b5fd7a736d5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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