我该怎么做? 我试图输入一些指定的链接(使用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(它基于mechanize)。它很容易使用,应该可以做你想做的。
它将如下所示:
一旦使用
go(...)
浏览到要登录的站点,就可以使用showforms()
列出所有表单。从python解释器中试试。通常您需要cookies来登录站点,这意味着cookielib、urllib和urllib2。下面是我在玩Facebook网络游戏时写的一节课:
您不一定需要HTTPS或重定向处理程序,但它们不会造成伤害,而且它使开放器更加健壮。你也可能不需要饼干,但很难仅仅从你发布的表单中分辨出来。我怀疑你可能,纯粹是从被评论掉的“记住我”输入。
让我试着简单一点,假设网站的URL是www.example.com,你需要填写用户名和密码来注册,所以我们现在进入登录页面说http://www.example.com/login.php,查看它的源代码并搜索动作URL,它将以类似于
现在让userinfo.php生成绝对URL,它将是http://example.com/userinfo.php,现在运行一个简单的python脚本
我希望有一天这能帮助别人。
相关问题 更多 >
编程相关推荐