使用curl编码URL变量 [英] Encode URL variable with curl

查看:290
本文介绍了使用curl编码URL变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似这样的休息端点 http://someurl.com/ {some_id}

I have a rest endpoint that looks like this http://someurl.com/{some_id}

我需要能够使用linux中的curl命令向该请求发出GET请求,并且我需要能够发送经过编码的可变网址

I need to be able to make a GET request to that using the curl command from linux, and I need to be able to send the variable url encoded

如果我尝试
curl -G -v'http://someurl.com'--data-urlencode's * 9678& as'它添加了?在前面,我希望能够将 some_id作为路径的一部分发送

if I try curl -G -v 'http://someurl.com' --data-urlencode 's*9678&as' it adds the ? in front, I want to be able to send the "some_id" as part of the path

推荐答案

使用 urlencode
如果在ubuntu上

Use urlencode. If on ubuntu

$ sudo apt-get install gridsite-clients

然后

$ curl -G -v  "http://someurl.com/$(urlencode 's*9678&as')"

这篇关于使用curl编码URL变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆