Python 填写网络论坛

发布于 2024-10-20 14:50:00 字数 234 浏览 10 评论 0原文

我正在尝试使用 python 登录此页面(我拥有!) http://ninitelist.yolasite。 com/passprotected.php 如果密码正确则返回 true,如果密码错误则返回 false。我完全不知道如何做到这一点,哦,请不要建议机械化,我不知道如何安装它。非常感谢!!

I am trying to use python to login to this page(which i own!) http://ninitelist.yolasite.com/passprotected.php
and return true if a password is correct and false if the password is wrong. I am at a total loss of how to do this, oh and please dont suggest mechanize, i cant figure out how to install it. Thanks very much!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌逼全场 2024-10-27 14:50:00

您可以使用Python的urllib来POST表单数据。

导入urllib

def try_login(username, password):
    params = urllib.urlencode(
            {'username': username,
             'password': password })
    f = urllib.urlopen("http://ninitelist.yolasite.com/passprotected.php", params)
    return "Invalid login details" not in f.read()

if __name__ == '__main__':
    print try_login("testuser", "testdata")

You can use Python's urllib to POST form data.

import urllib

def try_login(username, password):
    params = urllib.urlencode(
            {'username': username,
             'password': password })
    f = urllib.urlopen("http://ninitelist.yolasite.com/passprotected.php", params)
    return "Invalid login details" not in f.read()

if __name__ == '__main__':
    print try_login("testuser", "testdata")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文