Created
June 15, 2018 13:05
-
-
Save ScottSturdivant/28f897978922df1c72f25b22a34b38a4 to your computer and use it in GitHub Desktop.
This file contains 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 time | |
URL = 'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=kc35,kmke&hoursBeforeNow=2&mostRecentForEachStation=true&fields=flight_category,station_id,raw_text' | |
def test(): | |
success = failure = 0 | |
while True: | |
try: | |
response = requests.get(URL, timeout=10.0) | |
except: | |
pass | |
print(response.text) | |
if 'Invalid field name' in response.text: | |
failure += 1 | |
else: | |
success += 1 | |
total = success + failure | |
print(f'\nSuccess: {success}\nFailure: {failure}\nTotal: {total}\n\n\n') | |
time.sleep(60) | |
if __name__ == '__main__': | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment