美文网首页开发指南
shell命令行urlencode编码

shell命令行urlencode编码

作者: 墨韵 | 来源:发表于2021-09-02 23:15 被阅读0次
DATA=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])"  "$DATA")

我的案例

// test.sh

# url encode 编码
function urlEncode() {
    result=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "$1")
    echo $result
}

# 执行wget请求
function executeJson() {
    # 格式化显示json
    echo $1 | jq '.'
    adb shell "wget -O /sdcard/info.txt http://localhost:8089/service?data=$(urlEncode $1)"
    adb shell cat /sdcard/info.txt | jq '.'
    adb shell rm /sdcard/info.txt
}

# 请求json参数
json='{"data":"abc","type":1}'
# 执行wget请求
executeJson $json 
stackoverflow解答

相关文章

网友评论

    本文标题:shell命令行urlencode编码

    本文链接:https://www.haomeiwen.com/subject/svhhwltx.html