Created
March 14, 2020 08:21
Star
You must be signed in to star a gist
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
import csv | |
import sys | |
import json | |
from urllib import request, parse | |
from urllib.parse import quote | |
import time | |
features = [] | |
with open(sys.argv[1],'r') as csvfile: | |
reader = csv.DictReader(csvfile,delimiter="\t") | |
for row in reader: | |
address = row["縣市"] + row["行政區"] + row["段小段"] + row["母子號"] + "號" | |
url = "https://twland.ronny.tw/index/search?lands[]={0}".format(quote(address)) | |
resp = request.urlopen(url=url) | |
j = json.loads(resp.read()) | |
if len(j['features']) > 0: | |
features.append({'type':'Feature','properties':row,'geometry':j['features'][0]['geometry']}) | |
time.sleep(0.1) | |
print(json.dumps({'type':'FeatureCollection','features':features})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment