无法使用 wget 命令登录网站(shell 脚本)

unable to login into a website using wget commands (shell scripting)

我不明白的是我应该通过哪些输入字段,我试过了

wget --save-cookies cookies.txt --post-data "username=my_email_id" -d "password=my_pass" "https://ok.ru/https"     
wget --save-cookies cookies.txt --post-data "st.email=my_email_id" -d "st.password=my_pass" "https://ok.ru/https" 

我是否也应该传递所有其他输入字段值?有什么方法可以查看我的登录是否已被授权,以便我可以在登录后向其他页面发送获取请求。 以下是网站中使用的表格。

<form method="post" action="https://www.ok.ru/https">
    <input name="st.redirect" value="" type="hidden">
    <input name="st.asr" value="" id="field_asr" type="hidden">
    <input name="st.posted" value="set" type="hidden">
    <input name="st.originalaction" value="http://ok.ru/dk?cmd=AnonymLogin&amp;st.cmd=anonymLogin" id="field_originalaction" type="hidden">
    <input name="st.fJS" value="on" id="st.field_fJS" type="hidden">
    <input name="st.st.screenSize" value="1366 x 768" id="field_st.screenSize" type="hidden">
    <input name="st.st.browserSize" value="673" id="field_st.browserSize" type="hidden">
    <input name="st.st.flashVer" value="11.2.202" id="field_st.flashVer" type="hidden">
   <div class="hook">
       <script type="text/javascript">
document.getElementById('st.field_fJS').value='on';
document.getElementById('field_st.screenSize').value=screen.width + ' x ' + screen.height;
document.getElementById('field_st.browserSize').value=OK.util.getVpHeight();
document.getElementById('field_st.flashVer').value=(okFlashVersion||[]).join('.');
       </script></div>
    <label for="field_email" class="anonym_login_l">Username, e-mail or phone number</label>
    <div class="it_w">
       <input name="st.email" value="" id="field_email" class="it anonym_login_it " maxlength="100" type="text">
    </div>
    <label for="field_password" class="anonym_login_l">Password</label>
    <div class="it_w">
        <input maxlength="50" name="st.password" id="field_password" class="it anonym_login_it " type="password">
    </div>
    <div>
        <label for="field_remember" class="anonym_login_rem">
            <input name="st.remember" checked="checked" id="field_remember" class="anonym_log_rem_check" type="checkbox">
            <span class="anonym_log_rem_check_tx">Remember me</span>
        </label>
    </div>
    <input name="st.iscode" value="false" type="hidden"><input value="Log in" class="button-pro __orange inlineBlock" type="submit">
    <a href="/cdk/st.cmd/anonymPasswordRecovery?st._aid=LeftColumn_Login_ForgotPassword" class="al-log">Forgot password?</a>
</form>

我也试过使用

curl --user my_email_id:my_pass "https://www.ok.ru/https" -v

但是得到了这个

GET /https HTTP/1.1
> Authorization: Basic YmVya3NheUBtZS5jb206d2Fzd2VyZTEyMw==
> User-Agent: curl/7.35.0
> Host: www.ok.ru
> Accept: */*
> 
< HTTP/1.1 405 Method Not Allowed

我现在不知道如何进行。

如果您正在使用 wget(这就是您在示例中使用的),那么您应该将所有参数和值放在一起,用 & 个字符分隔,放在一个单一的文件中--post-data 选项的参数;像这样:

wget --save-cookies cookies.txt \
     --post-data "st.email=my_email_id&st.password=my_pass" \
     "https://ok.ru/https"

Should I pass all other input field values too?

这完全取决于您的需要。你想在输出中得到什么?您使用什么 wget 从 shell 访问表单而不是仅仅通过浏览器访问?你应该在你的问题中解释一下。

Is there any way where I can see if my login has been authorised, so that I can send a get request to other page after login.

您可以检查 shell 页面的输出(例如,使用 grep)是否有一些字符串表明身份验证成功。