Last active
August 29, 2015 14:20
-
-
Save n0531m/e7c9ffb0607c26f3b448 to your computer and use it in GitHub Desktop.
list ksj zip file urls
This file contains 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
# http://nlftp.mlit.go.jp/ksj/api/about_api.html | |
# sudo port install py27-lxml | |
#sudo easy_install pip | |
#xcode-select --install | |
#sudo pip install lxml | |
import urllib2 | |
from lxml import etree | |
def listKsjZipFileUrls(): | |
url_summary="http://nlftp.mlit.go.jp/ksj/api/1.0b/index.php/app/getKSJSummary.xml?appId=ksjapibeta1&lang=J&dataformat=1" | |
#response=urllib2.urlopen(url_summary) | |
#xml=response.read() | |
#root=etree.fromstring(xml) | |
root=etree.parse(url_summary) | |
r=root.xpath("//item/identifier/text()"); | |
#print len(r) | |
for identifier in r: | |
url="http://nlftp.mlit.go.jp/ksj/api/1.0b/index.php/app/getKSJURL.xml?appId=ksjapibeta1&dataformat=1&identifier="+identifier | |
datatree=etree.parse(url); | |
files=datatree.xpath("//item/zipFileUrl/text()"); | |
for file in files: | |
print file | |
# print identifier | |
# print r | |
#return xml | |
listKsjZipFileUrls() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment