How to login to a website with python and mechanize
Why not use a browser instance to facilitate navigation? Mechanize also has the ability to select particular forms (e.g. nr = 0 will select the first form on the page)
browser = mechanize.Browser()browser.open(YOUR URL)browser.select_form(nr = 0)browser.form['username'] = USERNAMEbrowser.form['password'] = PASSWORDbrowser.submit()
Web automation ? Definitely "WEBBOT"
webbot
works even for webpages with dynamically changing id and classnames and has more methods and features than selenium.
Here's a snippet :)
from webbot import Browser web = Browser()web.go_to('google.com') web.click('Sign in')web.type('mymail@gmail.com' , into='Email')web.click('NEXT' , tag='span')web.type('mypassword' , into='Password' , id='passwordFieldId') # specific selectionweb.click('NEXT' , tag='span') # you are logged in ^_^