Login to a Website Using Script

How to login to a website by using Python

Perhaps it is expecting User not username:

url = 'http://12.345.67.891:8000/login'
values = {'User': 'abcdefg',
'password': 'apple'}

r = requests.post(url, data=values)
print(r.content)

How can I login to a website with Python?

Maybe you want to use twill. It's quite easy to use and should be able to do what you want.

It will look like the following:

from twill.commands import *
go('http://example.org')

fv("1", "email-email", "blabla.com")
fv("1", "password-clear", "testpass")

submit('0')

You can use showforms() to list all forms once you used go… to browse to the site you want to login. Just try it from the python interpreter.



Related Topics



Leave a reply



Submit