cURL:如何制作登录脚本(使用https协议)?

时间:2012-04-01 01:54:32

标签: curl

这是一个简单的登录页面,可用作4shared.com的登录面板:

<form id="login_form" method="post" action="https://www.4shared.com/index.jsp">   
    <input type="text" placeholder="username" name="login" id="iloginfield">
    <input type="password" placeholder="password here" name="password" id="ipassfield">
    <input type="submit"  value="Login">
</form>

有效。 我想我可以简单地跑:

curl  "http://www.4shared.com/index.jsp" -d "login=xxxxxxx&password=yyyyyyyyyyyyy" -D "/tmp/header.txt"

哪个应该有效。 但它失败了。

为什么呢?我该怎么做?

1 个答案:

答案 0 :(得分:0)

您看到了什么输出?您可能希望存储服务器发送给您的cookie。

   -c/--cookie-jar <file name>
          Specify to which file you want curl to write all cookies after a
          completed  operation.  Curl  writes  all cookies previously read
          from a specified file as  well  as  all  cookies  received  from
          remote server(s). If no cookies are known, no file will be writ‐
          ten. The file will be written using  the  Netscape  cookie  file
          format.  If  you  set  the  file name to a single dash, "-", the
          cookies will be written to stdout.

          NOTE If the cookie jar can't be created or written to, the whole
          curl operation won't fail or even report an error clearly. Using
          -v will get a warning displayed, but that is  the  only  visible
          feedback you get about this possibly lethal situation.

          If  this  option  is used several times, the last specified file
          name will be used.