Skip to content

Instantly share code, notes, and snippets.

@coeric
Created April 30, 2018 07:09
Show Gist options
  • Save coeric/fe3329d38282b6ece1cd927905c228a8 to your computer and use it in GitHub Desktop.
Save coeric/fe3329d38282b6ece1cd927905c228a8 to your computer and use it in GitHub Desktop.
#-*- 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