title: Using Mechanize To login to gmail
body: <p>I am trying to scrap gmail.com and have used mechanize to authenticate but since gmail has two step authentication it was quite tricky but i managed to login but i face loading problem. 
  My code is</p>
  
  <pre><code>from os import system
  import sys
  import speech_recognition as sr
  import pyaudio
  import urllib, urllib2
  from bs4 import BeautifulSoup, Comment
  import unicodedata
  import mechanize
  import cookielib
  import time
  
  
  cj = cookielib.CookieJar()
  br = mechanize.Browser() 
  br.set_handle_robots(False)
  br.set_cookiejar(cj)
  br.open("https://www.gmail.com")
  
  br.select_form(nr=0)
  br.form.set_all_readonly(False)
  br.form['Email'] = 'vivek0293@gmail.com'
  
  br.submit()
  
  br.select_form(nr=0)
  br.form['Passwd'] = '*******'
  br.submit()
  
  print"Success"
  
  soup = BeautifulSoup(br.response().read(),"html.parser")
  
  for row in soup.find_all('div'):
      print "hi"
      print row.text
  </code></pre>
  
  <p>My Output looks like this:</p>
  
  <p>/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7      /Users/vivekrahul/PycharmProjects/untitled/sample.py
  Success
  hi</p>
  
  <p>hi
  Loading vivek0293@gmail.com…Loading standard view |  (for slow connections)This is taking longer than usual. Try reloading the page.If that doesn't work, you can:Disable Labs and try again.If you're on a slow connection, try .For more troubleshooting tips, visit the Help Centre.
  hi
  Loading vivek0293@gmail.com…
  hi
  Loading vivek0293@gmail.com…
  hi</p>
  
  <p>hi</p>
  
  <p>hi
  Loading standard view |  (for slow connections)
  hi
  This is taking longer than usual. Try reloading the page.If that doesn't work, you can:Disable Labs and try again.If you're on a slow connection, try .For more troubleshooting tips, visit the Help Centre.
  hi
  If that doesn't work, you can:Disable Labs and try again.If you're on a slow connection, try .For more troubleshooting tips, visit the Help Centre.
  hi</p>
  
  <p>Process finished with exit code 0</p>