title: Google Trends - Quota limit - IP address changer
body: <p>I am writing a code using the Unofficial Google Trends API (<a href="https://github.com/GeneralMills/pytrends#trend" rel="nofollow noreferrer">https://github.com/GeneralMills/pytrends#trend</a>), however after hardly 10 requests I have got the following error: <code>Exceeded Google's Rate Limit. Please use time.sleep() to space requests.</code></p>
  <p>It seems that the following command does not properly connect to Google services.</p>
  <pre><code>  pytrends = TrendReq(google_username, google_password, custom_useragent=None)
  </code></pre>
  <p>Therefore I tried to change my IP address along with Tor Browser as explained here: <a href="https://stackoverflow.com/a/34516846/7110706">https://stackoverflow.com/a/34516846/7110706</a></p>
  <pre><code>controller = Controller.from_port(port=9151)
  
  def connectTor():
      socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 , &quot;127.0.0.1&quot;, 9150, True)
      socket.socket = socks.socksocket
  
  def renew_tor():
      controller.authenticate()
      controller.signal(Signal.NEWNYM)
  
  def showmyip():
      url = &quot;http://www.showmyip.gr/&quot;
      r = requests.Session()
      page = r.get(url)
      soup = BeautifulSoup(page.content, &quot;lxml&quot;)
      ip_address = soup.find(&quot;span&quot;,{&quot;class&quot;:&quot;ip_address&quot;}).text.strip()
      print('New IP adress is:' + ip_address)
  </code></pre>
  <p>There main issue is in the following code:</p>
  <pre><code>def requestDailydatafromGT(keywords, geography, date):  #parameters must be strings 
      from pytrends.request import TrendReq
      import time
      from random import randint 
      
      google_username = &quot;&quot;  #put your gmail account
      google_password = &quot;&quot;
      path = &quot;&quot;
  
      #Connect to google
      pytrend = TrendReq(google_username, google_password, custom_useragent=None)
  
      requestdate=str(date)+' 3m'
          
      trend_payload = {'q': keywords,'hl': 'en-US','geo': geography, 'date': requestdate} #define parameters of the request
      mes=0
      
      while mes==0:
          try:
              results= pytrend.trend(trend_payload, return_type='dataframe').sort_index(axis=0, ascending=False) #launch request in Google tren0ds
              mes=1
          
          except Exception:
              renew_tor()
              connectTor()
              time.sleep(randint(5,15))
              mes=0
          
      return results
  </code></pre>
  <p>The code seems to work as the IP address changes over the time, however I am still stuck with Google request quota limit error:</p>
  <blockquote>
  <p>Exceeded Google's Rate Limit. Please use time.sleep() to space requests.</p>
  <p>New IP address is : 178.217.187.39</p>
  <p>Exceeded Google's Rate Limit. Please use time.sleep() to space requests.</p>
  <p>New IP address is: 95.128.43.164</p>
  </blockquote>
  <p>Do you know if there is a way to bypass the limitation? Perhaps Google Trends does not get the new IP address as the request is not correctly routed by thor.</p>
  <p>Thanks in advance.</p>