title: Failure to change identify using Tor when scraping google
body: <p>I am trying to automate google search but unfortunately my IP is blocked. After some searches, it seems like using <code>Tor</code> could get me a new IP dynamically. However, after adding the following code block into my existing code, google still blocks my attempts even under the new IP. So I am wondering is there anything wrong with my code?</p>
  <h3>Code (based on <a href="https://stackoverflow.com/a/10193956/1231509">this</a>)</h3>
  <pre><code>from TorCtl import TorCtl
  import socks
  import socket
  import urllib2
  
  socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, &quot;127.0.0.1&quot;, 9050)
  
  
  __originalSocket = socket.socket
  
  def newId():
      ''' Clean circuit switcher
  
      Restores socket to original system value.
      Calls TOR control socket and closes it
      Replaces system socket with socksified socket
      '''
      socket.socket = __originalSocket
      conn = TorCtl.connect(controlAddr=&quot;127.0.0.1&quot;, controlPort=9051, passphrase=&quot;mypassword&quot;)
      TorCtl.Connection.send_signal(conn, &quot;NEWNYM&quot;)
      conn.close()
      socket.socket = socks.socksocket
  
  ## generate a new ip
  newId()
  
  ### verify the new ip
  print(urllib2.urlopen(&quot;http://icanhazip.com/&quot;).read())
  
  ## run my scrape code
  google_scrape()
  </code></pre>
  new error message
  <pre><code>&lt;br&gt;Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
  &lt;/div&gt;
  
  IP address: 89.234.XX.25X&lt;br&gt;Time: 2017-02-12T05:02:53Z&lt;br&gt;
  </code></pre>