Created
March 29, 2019 13:13
-
-
Save jen6/0768dfde0dfff9df55ae83daaa52aa5f 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
#!/bin/bash | |
if [ "$#" -lt 2 ]; then | |
echo "$# is Illegal number of parameters." | |
echo "Usage: $0 [input.csv] [kakao rest api key]" | |
exit 1 | |
fi | |
while read LINE; do | |
RESULT=`curl -vs -X GET "https://dapi.kakao.com/v2/local/search/address.json"\ | |
--data-urlencode "query=${LINE}" \ | |
-H "Authorization: KakaoAK $2"`; | |
DATA=`echo "${RESULT}" \ | |
| python -c "import sys,json; parsed = json.load(sys.stdin)['documents'][0]; \ | |
print(parsed['x'].encode('ascii'), parsed['y'].encode('ascii'))"`; | |
if [ -z "$DATA" ]; then | |
printf '\n' >> out.csv; | |
else | |
echo $DATA >> out.csv; | |
fi | |
sleep 2; | |
done < $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment