Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_last_100_year_data():
- for year in range(1919, 2019):
- url = "https://earthquake.usgs.gov/fdsnws/event/1/" \
- "query?format=geojson&starttime={}-01-01&endtime={}-12-31&minmagnitude=3".format(year, year)
- try:
- response = requests.get(url)
- except requests.ConnectionError or requests.HTTPError:
- print('Error while contacting {}'.format(url))
- continue
- features = response.json()['features']
- for feature in features:
- lat, lon, _ = feature['geometry']['coordinates']
- magnitude = feature['properties']['mag']
- epoch_time_milli = float(feature['properties']['time'])
- datetime_object = datetime.fromtimestamp(epoch_time_milli/1000)
- print(lat, lon, magnitude, str(datetime_object))
- get_last_100_year_data()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement