Reputation: 59
I'm playing around with mechanize on a website that appears differently based on your ip.
Is there a way to change you ip in mechanize?
I've tried:
br.set_proxies({"http": '127.0.0.1:80'})
but that timesout. Is there something else I'm supposed to do to make this work?
Upvotes: 2
Views: 1119
Reputation: 1
You can use tor with menchanize it will allowed you tu use different IP and anonymous.
import socks
import socket
def create_connection(address, timeout=None, source_address=None):
sock = socks.socksocket()
sock.connect(address)
return sock
And This code before create the browser of mechanize
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
socket.socket = socks.socksocket
socket.create_connection = create_connection
Upvotes: 0
Reputation: 60604
no, I do not believe this is possible. IP address is set on outgoing packets by your network stack, outside of mechanize's control.
Upvotes: 1