Created
April 30, 2018 07:09
-
-
Save coeric/fe3329d38282b6ece1cd927905c228a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
#!/usr/bin/env python | |
import zipfile | |
import urllib | |
dataid="F-D0047-093" | |
token="my_token" | |
url="http://opendata.cwb.gov.tw/opendataapi?dataid={}&authorizationkey={}".format(dataid,token) | |
urllib.urlretrieve(url,'temp.zip') | |
for file in zipfile.ZipFile('temp.zip',"r").namelist(): | |
data=zipfile.ZipFile('temp.zip').open(file,'r' ) | |
outpath='/home/myname/download/{}'.format(file) | |
f=open(outpath,'w') | |
f.write(data.read()) | |
data.close() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment