Using Proxies with Python Requests (Pytrends)

106 Views Asked by At

i'm currently learning how to use Python with API's and am having trouble with using proxies when making requests, in this case I am using Pytrends.

Here is my code

`pytrends = TrendReq(hl='en-US', tz=360, timeout=(10, 25), retries=2, backoff_factor=0.1 proxies = ['https': 'https://geo.iproyal.com:redacted'])`
                    pytrends.build_payload(kw_list=[keyword], geo=location)
                    data = pytrends.interest_over_time()
                    df = pd.DataFrame(data)
                    uk_data = int(df.iloc[-1][keyword])

Getting This Error

line 84, in GetGoogleCookie
    proxy = {'https': self.proxies[self.proxy_index]}
                      ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 0

Thanks.

Tried to use residential proxies from IP Royal however have received the error displayed above, any ideas?

0

There are 0 best solutions below