开发者

Python to fill out web forum

开发者 https://www.devze.com 2023-02-15 17:39 出处:网络
I am trying to use python to login to this page(which i own!) http://ninitelist.yolasite.com/passprotected.php

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 lo开发者_运维百科ss of how to do this, oh and please dont suggest mechanize, i cant figure out how to install it. Thanks very much!!


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")
0

精彩评论

暂无评论...
验证码 换一张
取 消