Created
September 18, 2018 08:22
-
-
Save kiuchikeisuke/51e4f923183493af61d7b179a3050637 to your computer and use it in GitHub Desktop.
shellでcurlコマンドを使って無理やりURLエンコードする方法 ref: https://qiita.com/k_keisuke/items/321407a500edf20bfb13
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
HOST="https://sample.co.jp" | |
URL="" | |
while IFS='\&' read P1 P2;do | |
# curlのrequestログを一時的なファイルに書き出す | |
curl ${URL} -v --verbose --get --data-urlencode "${P1}" --data-urlencode "${P2}" 1> /dev/null 2>temp_log | |
# curlのログからurlEncodeされたリクエストを取り出し、Hostとくっつける | |
while read Q1 Q2 Q3 Q4;do | |
URL=`echo ${HOST}${Q3}` | |
done <<< `grep -E "> GET .+ HTTP/1\.[0-9]" temp_log` | |
done <<< `sample_query` | |
rm temp_log |
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
p=あいうえお&q=かきくけこ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment