# L-6 MCS 275 Mon 23 Jan 2017 : getwebdata.py
"""
The script below gets information about earthquakes in csv format.
We read the data and copy into the file "quakes.csv".
"""

from urllib.request import urlopen

SITE = "http://earthquake.usgs.gov"
URL = SITE + "/earthquakes/feed/v1.0/summary/all_month.csv"

INFILE = urlopen(URL)
OUTFILE = open('quakes.csv', 'w')
while True:
    LINE = INFILE.readline()
    if LINE == b'':
        break
    OUTFILE.write(LINE.decode())
INFILE.close()
OUTFILE.close()
