Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

curl 如何传递多参数并进行urlencode

1.curl进行urlencode的方式为curl --data-urlencode "port=4546&content=hello" www.test.com

但是这样服务器并不能正常获取port和content参数,反而获得的参数是port,值为4546&content=hello

2.curl进行多参数post的方式为curl -d "port=4546&content=哈哈哈" www.test.com

但是这样得到的参数并没有进行url编码,如何得到content为%e5%93%88%e5%93%88%e5%93%88,而不是哈哈哈

3.综上,能否仅用curl就完成多参数的发送(post,get不限)与url编码,如何做?

注:仅限shell命令,若先传数据过去再在服务器进行高级语言的url编码非本问题讨论范围


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
curl -G --data-urlencode "port=4546" --data-urlencode "content=哈哈哈" www.test.com

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...