br.open('http://yoursite.com/login')
br.select_form(nr=1)
br['username'] = 'yourUserName'
br['password'] = 'yourPassword'
response = br.submit()
How to get mechanize requests to look like they originate from a real browser