python - 如何使用 Python 登录网站?

标签 python automation httpclient webautomation

我该怎么做? 我试图输入一些指定的链接(使用 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/

相关文章:

python - 矢量到字符串,保存在文件中,然后再到矢量? Python

automation - 使用脚本将 ttf/woff/woff2 文件重命名为 PostScript 字体名称

c# - HttpClient 请求有时在 C# 中失败

java - httpclient - 在 POST 消息中使用 cookie

python - 使用列表作为类参数

python - 使用shell脚本并行执行多个脚本

python - "gaierror: [Errno -3] Temporary failure in name resolution"是什么意思

c++ - 如何使用 Qt 将颜色应用于 Excel 单元格?

javascript - 在 Facebook Messenger 上使用 puppeteer 时没有选择器 Node

image - WP 8.1 从 http 请求绑定(bind)图像