用curl命令,post提交带空格的数据
2023-03-14 10:21:04 时间
今天偶然遇到一个情况,我想用curl登入一个网页,无意间发现要post的数据里带空格。比如用户名为"abcdef",密码为"abc def",其中有一个空格,按照我以前的方式提交:
curl -D cookie -d "username=abcdef&password=abc def" http://login.xxx.com/
提示登入失败。
于是查看curl手册man curl。找到:
d/--data (HTTP) Sends the specified data in a POST request to the HTTP server, in a way that can emulate as if a user has filled in a HTML form and pressed the submit button. Note that the data is sent exactly as specified with no extra processing (with all newlines cut off). The data is expected to be "url-encoded". This will cause curl to pass the data to the server using the content-type applica- tion/x-www-form-urlencoded. Compare to -F/--form. If this option is used more than once on the same command line, the data pieces specified will be merged together with a separating &-letter. Thus, using ’-d name=daniel -d skill=lousy’ would generate a post chunk that looks like ’name=daniel&skill=lousy’.
于是改用:
curl -D cookie -d "username=abcdef" -d "password=abc efg" http://login.xxx.com/
这样就能成功登入了。
版权声明
本人的所有原创文章皆保留版权,请尊重原创作品。
转载必须包含本声明,保持本文完整,并以超链接形式注明原始作者“redraiment”和主站点上的本文原始地址。
联系方式
我的邮箱,欢迎来信(redraiment@gmail.com)
我的Blogger(子清行)
我的Google Sites(子清行)
我的CSDN博客(梦婷轩)
我的百度空间(梦婷轩)
相关文章
- Redis开发与运维. 2.7 键管理
- Redis开发与运维. 2.8 本章重点回顾
- Redis开发与运维. 3.1 慢查询分析
- Redis开发与运维. 3.2 Redis Shell
- Redis开发与运维. 3.3 Pipeline
- Redis开发与运维. 3.4 事务与Lua
- Redis开发与运维. 3.5 Bitmaps
- 有效统计实践的十项简明原则
- Redis开发与运维. 3.7 发布订阅
- Redis开发与运维. 3.8 GEO
- Redis开发与运维. 3.9 本章重点回顾
- 数据可视化:如何利用色彩来佐证观点
- D-News大数据新闻Top10|阿里财报公布 AI领域新动态
- 特征工程:数据科学家的秘密武器!
- 机器学习为何重要|通过计算一个句子的音节总数证明给你看
- 5月16日云栖精选夜读:从0到1构建大数据生态系列1:数据蛮荒中的拓荒之举
- 对话Hadoop之父Doug Cutting|大数据和开源的未来
- 大数据与机器学习:实践方法与行业案例.1.2数据平台
- 大数据与机器学习:实践方法与行业案例.1.4 本章小结
- 大数据与机器学习:实践方法与行业案例.3.3 自动加载程序的数据库设计