import os import requests for x in range(1900,2016): for y in range(1,13): url='https://earthquake.usgs.gov/fdsnws/event/1/query.csv?starttime='+str(x)+'-'+str(y)+'-31%2023:59:59&endtime='+str(x)+'-'+ str(y+1) +'-31%2023:59:59&minmagnitude=2.5&orderby=time' print(url) response = requests.get(url) with open(os.path.join("C:/Users/kristjag/OneDrive/delo/potresi", "potresi_"+str(x)+"_"+str(y)+".csv"), 'wb') as f: f.write(response.content)
Code above take some time to finish but when completed you get earthquake data for every month from 1900-2016