Skip to content

Instantly share code, notes, and snippets.

@ScottSturdivant
Created June 15, 2018 13:05
Show Gist options
  • Save ScottSturdivant/28f897978922df1c72f25b22a34b38a4 to your computer and use it in GitHub Desktop.
Save ScottSturdivant/28f897978922df1c72f25b22a34b38a4 to your computer and use it in GitHub Desktop.
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