我该怎么做? 我试图输入一些指定的链接(使用 urllib),但要这样做,我需要登录。
我有这个网站的来源:
<form id="login-form" action="auth/login" method="post">
<div>
<!--label for="rememberme">Remember me</label><input type="checkbox" class="remember" checked="checked" name="remember me" /-->
<label for="email" id="email-label" class="no-js">Email</label>
<input id="email-email" type="text" name="handle" value="" autocomplete="off" />
<label for="combination" id="combo-label" class="no-js">Combination</label>
<input id="password-clear" type="text" value="Combination" autocomplete="off" />
<input id="password-password" type="password" name="password" value="" autocomplete="off" />
<input id="sumbitLogin" class="signin" type="submit" value="Sign In" />
这可能吗?
最佳答案
也许您想使用 twill .它很容易使用,应该可以做你想做的事。
它将如下所示:
from twill.commands import *
go('http://example.org')
fv("1", "email-email", "blabla.com")
fv("1", "password-clear", "testpass")
submit('0')
您可以使用 showforms()
列出所有表单,一旦您使用 go...
浏览到您要登录的站点。只需从 python 解释器中尝试。
关于python - 如何使用 Python 登录网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2910221/