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")
精彩评论