Like the title says, my code basically does this:
set proxy, test proxy, do some cool stuff
But after the proxy is set the first time, it sticks that way, never changing. This is the failing code:
# Pick proxy
r = random.randint(0, len(proxies) - 1)
proxy = proxies[r]
print proxy
# Setup proxy
l_proxy_support = urllib2.ProxyHandler({"http": "http://{0}:{1}".format(*proxy)})
l_opener = urllib2.build_opener(l_proxy_support)
try:
l_req = l_opener.open(
urllib2.Request('http://[MYIPADDRESSHERE]/ip.php', None, agent)
)
print l_req.read()
except urllib2.URLError:
print "Proxy not functioning, aborting..."
# Do cool stuff here, not really relevant
The output ends up being:
['X.Y.Z.124', '666', 'http']
[Skarlet] Your IP address is: X.Y.Z.124
['X2.Y2.Z2.190', '666', 'http']
[Skarlet] Your IP address is: X.Y.Z.124
['X3.Y3.Z3.41', '666', 'http']
[Skarlet] Your IP address is: X.Y.Z.124
I'm really puzzled right now.
Thanks for your time.
PD: the script that responds from my home IP address is just a PHP echoing $_SERVER['REMOTE_ADDR'].