def getEvents(magnitude=1.0,significance=0,product='dyfi',lastUpdate=2678000):
"""
Return a list of earthquake event urls that meet the conditions set above.
Inputs:
* magnitude: Event magnitude (OR condition with significance)
* significance: Event significance (integer score assembled from weighting magnitude, PAGER alert level, Max MMI, etc.)
* lastUpdateDelta: Only retrieve events that have been updated in the past lastUpdate minutes.
* product: Only retrieve events that have this product type associated with them.
"""
fh = urllib2.urlopen(FEEDURL)
data = fh.read()
fh.close()
jdict = json.loads(data)
eventurls = []
tnow = datetime.utcnow()
for event in jdict['features']:
eurl = event['properties']['detail']
emag = event['properties']['mag']
esig = event['properties']['sig']
etypes = event['properties']['types'].split(',')[1:-1]
eupdate = datetime.utcfromtimestamp(event['properties']['updated']/1000)
hasproduct = product in etypes
if not hasproduct:
continue
if eupdate < tnow - timedelta(seconds=60*lastUpdate):
continue
eventurls.append(eurl)
return eventurls
评论列表
文章目录