免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1287 | 回复: 7
打印 上一主题 下一主题

curl 上传数据的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-29 22:05 |只看该作者 |倒序浏览
用curl能以各种协议下载,它有没有上传数据的功能呢?
比如说CU发表话题(或回复)的表单的提交?

[ 本帖最后由 bitmilong 于 2005-11-30 21:53 编辑 ]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2005-11-29 22:09 |只看该作者
可以的.
不过涉及到表单可就复杂了.有的有hidden的.还有验证表单的方式也不相同.

论坛徽章:
0
3 [报告]
发表于 2005-11-29 22:35 |只看该作者
谢谢110,你说的是这个吧

-d/--data <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 application/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'.

If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be url-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar".

To post data purely binary, you should instead use the --data-binary option.

-d/--data is the same as --data-ascii.

If this option is used several times, the ones following the first will append data.

论坛徽章:
0
4 [报告]
发表于 2005-11-29 22:46 |只看该作者
原帖由 mq110 于 2005-11-29 22:09 发表
可以的.
不过涉及到表单可就复杂了.有的有hidden的.还有验证表单的方式也不相同.




type="hidden" 是指什么意思 ?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2005-11-30 12:30 |只看该作者
原帖由 bitmilong 于 2005-11-29 22:46 发表




type="hidden" 是指什么意思 ?


隐藏域.有些数据可以隐式的提交的.好久都没做网站了 汗.

不同的动态网页由于设计者的不同 而采取不同的方式.拿CU来说.想要做个自动表单提交的程序可不容易.有验证码的.需要你能够找到一个方式来处理验证码. 所以不提倡用CURL来做. 太麻烦啦.

[ 本帖最后由 mq110 于 2005-11-30 12:56 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2005-11-30 21:53 |只看该作者
原帖由 mq110 于 2005-11-30 12:30 发表


隐藏域.有些数据可以隐式的提交的.好久都没做网站了 汗.

不同的动态网页由于设计者的不同 而采取不同的方式.拿CU来说.想要做个自动表单提交的程序可不容易.有验证码的.需要你能够找到一个方式来处理验证码 ...




只是举个例子,做CU的自动表单提交也没啥意思,俺又没想发广告

隐式的表单和非隐式的表单的提交有什么差别吗?

type="hidden" ,就是在页面中不显示,用curl的话影响不大,加个判断就成了吧

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
7 [报告]
发表于 2005-11-30 22:00 |只看该作者
原帖由 bitmilong 于 2005-11-30 21:53 发表




只是举个例子,做CU的自动表单提交也没啥意思,俺又没想发广告

隐式的表单和非隐式的表单的提交有什么差别吗?

type="hidden" ,就是在页面中不显示,用curl的话影响不大,加个判断就成了吧


有差别的. 以前我做网站的时候(php) 曾经加过隐藏的域.提交过来的数据判断一下. 现在的问题是 如果你没有动态页的代码.很有可能你写出来的程序最终会提交失败.

论坛徽章:
0
8 [报告]
发表于 2005-11-30 22:58 |只看该作者
原帖由 mq110 于 2005-11-30 22:00 发表


有差别的. 以前我做网站的时候(php) 曾经加过隐藏的域.提交过来的数据判断一下. 现在的问题是 如果你没有动态页的代码.很有可能你写出来的程序最终会提交失败.



这是个问题,还没有找到类似的例子,得试试才行


btw:通过这两天对curl的研究,确实佩服其功能的强大
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP