Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Created November 10, 2014 14:26
Show Gist options
  • Save t0mst0ne/8f14e0875a875fe24f55 to your computer and use it in GitHub Desktop.
Save t0mst0ne/8f14e0875a875fe24f55 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ptyhon
#coding:UTF-8
import xml.etree.cElementTree as ET
import requests
import pandas as pd
import datetime, os
# Official explaination of dataset :http://data.gov.tw/node/7504
os.environ['TZ'] = 'ROC'
url = 'http://data.gov.tw/iisi/logaccess?dataUrl=http%3A%2F%2Fwww.land.moi.gov.tw%2Fngis%2Fnewpic%2Frss%2Fquery3.xml&type=XML&nid=7504'
XML = requests.get(url)
root2 = ET.fromstring(XML.content)
mylist2 = [{child3.tag:child3.text for child3 in child_of_root2 } for child_of_root2 in root2]
df = pd.DataFrame(mylist2)
today = datetime.datetime.now().strftime('%Y-%m-%d')
df.to_csv('%sland.csv' % (today),encoding='utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment