I have a list of let's say 100 URLS.
I want to change IP after every 10 URLS.
Let's say I have my own proxies that I'd like to use after each 10 URLS.
How would I use that proxy in my requests - ?
list = [100URLS items]
for urls in list:
##request 10 URLS here then it might throw me error.
#After it throws me error, I want to be able to use proxies inside a list something like this and reiterate the same request with a new proxy using requests.
#!/usr/bin/python import requests proxy = '' list = ['http://proxy1','http://proxy2'] count = 0 def proxy_changer(): try: proxy_num = count + 1 proxy = list[proxy_num] return proxy except: print "you are out of proxies" def open_site(): requests.get('http://example.org', proxies=proxy_changer()) proxy_changer()
Hopefully this helps as the question is not clear. This will change the proxy