Skip to content

Instantly share code, notes, and snippets.

@kiuchikeisuke
Created September 18, 2018 08:22
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 kiuchikeisuke/51e4f923183493af61d7b179a3050637 to your computer and use it in GitHub Desktop.
Save kiuchikeisuke/51e4f923183493af61d7b179a3050637 to your computer and use it in GitHub Desktop.
shellでcurlコマンドを使って無理やりURLエンコードする方法 ref: https://qiita.com/k_keisuke/items/321407a500edf20bfb13
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
p=あいうえお&q=かきくけこ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment