开发者

Python to fill out web forum

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜