Skip to content

Instantly share code, notes, and snippets.

@jen6
Created March 29, 2019 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jen6/0768dfde0dfff9df55ae83daaa52aa5f to your computer and use it in GitHub Desktop.
Save jen6/0768dfde0dfff9df55ae83daaa52aa5f to your computer and use it in GitHub Desktop.
#!/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