python post登录表单超时

时间:2016-01-21 06:15:47

标签: python post login

我正试着从其他网页登录代码。 发送命令行到登录后,脚本启动,带有连接网页的超时结果通知 我不知道代码中的问题在哪里。 我正在使用python 2.7.11 有什么建议吗?

网页代码

<form id="registration" action="/auth/login" method="post">                <strong style="color:red"><br></strong>
                <ul class="form register">
                    <li>
                        <label>Email *</label>
                        <span class="txt">
                            <input class="main-login" name="LoginForm[email]" id="LoginForm_email" type="text">                        </span>
                    </li>
                    <li>
                        <label>Password *</label>
                        <span class="txt">
                            <input class="main-login" name="LoginForm[password]" id="LoginForm_password" type="password">                        </span>
                    </li>
                    <li>
                        <div class="agree">
                            <input id="ytagr" type="hidden" value="0" name="LoginForm[rememberMe]"><input class="ch" id="agr" checked="checked" name="LoginForm[rememberMe]" value="1" type="checkbox">                            <label for="LoginForm_rememberMe">remember me</label>                        </div>
                    </li>
                    <li style="display: none">
                        <label>Enter code *</label>

                        <div class="capcha" style="width: 300px;">
                                                        <img visible="" width="118" height="44" btn_id="gr3tefg_1" id="yw0" src="/auth/captcha/v/56a07618bbd42" alt="">                                                        <div class="code">
                                <span class="txt sm">
                                    <input name="LoginForm[verifyCode]" id="LoginForm_verifyCode" type="text"><br>
                                </span>
                                <a id="gr3tefg_1"></a><div><a id="yw0_button" href="/auth/captcha/refresh/1">Refresh</a></div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <label></label>
                        <a class="btn send-message" onclick="document.forms.registration.submit();"><span>Enter</span></a>
                    </li>
                    <li>
                        <label></label>
                        <a href="/account/ForgotPassword" class="restore">Forgot password</a>
                    </li>
                </ul>
                </form>

我的应用代码:

import urllib
import urllib2
import cookielib
...
    username = "XXXXXXXXXXX"
    password = "XXXXXXXXXXX"
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    login_data = urllib.urlencode({'LoginForm[email]' : username, 'LoginForm[password]': password})
    opener.open("https://rapidgator.net/auth/login", login_data)
    resp = opener.open("http://rapidgator.net/filesystem/index")
...

0 个答案:

没有答案