Skip to content

Instantly share code, notes, and snippets.

@woohgit
Created August 21, 2017 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woohgit/d77ea7fe23d8cee59173aef01d2b99bd to your computer and use it in GitHub Desktop.
Save woohgit/d77ea7fe23d8cee59173aef01d2b99bd to your computer and use it in GitHub Desktop.
Earthquake feeds (3)
import urllib
import json
def report_eq():
# API documentation:
# https://earthquake-report.com/2013/06/29/earthquake-report-com-json-and-rss-feeds/
url = "http://earthquake-report.com/feeds/recent-eq?json"
try:
entries = json.loads(urllib.urlopen(url).read())
for entry in entries:
if "JAPAN" in entry['location'].upper():
jishin = entry
break
except Exception:
pass
# API documentation:
# http://www.p2pquake.com/dev/?q=json-api
url = "http://api.p2pquake.com/v1/human-readable"
try:
entries = json.loads(urllib.urlopen(url).read())
for entry in entries:
if "_id" in entry:
jishin2 = entry
except Exception:
pass
# API documentation:
# https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson"
try:
entries = json.loads(urllib.urlopen(url).read())
for entry in entries["features"]:
if "JAPAN" in entry['properties']['place'].upper():
jishin3 = entry
break
except Exception:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment