MCPcopy Create free account
hub / github.com/LinkedInLearning/learning-python-2896241 / main

Function main

Ch5 - Internet Data/jsondata_finished.py:44–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def main():
45 # define a variable to hold the source URL
46 # In this case we'll use the free data feed from the USGS
47 # This feed lists all earthquakes for the last day larger than Mag 2.5
48 urlData = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_day.geojson"
49
50 # Open the URL and read the data
51 webUrl = urllib.request.urlopen(urlData)
52 print("result code: " + str(webUrl.getcode()))
53 if (webUrl.getcode() == 200):
54 data = webUrl.read().decode("utf-8")
55 # print out our customized results
56 printResults(data)
57 else:
58 print("Received an error from server, cannot retrieve results " +
59 str(webUrl.getcode()))
60
61
62if __name__ == "__main__":

Callers 1

Calls 1

printResultsFunction · 0.70

Tested by

no test coverage detected