Ip Remains Unchanged
I am trying to connect to Tor by code and change my identity. The results that I have gotten so far are that I connect successfully but can't change my identity. Here is my code :
Solution 1:
If you are using a unix based OS you can use subprocess and killall with HUP to create a new identity:
url = 'http://my-ip.heroku.com'
import socks
import socket
socks.set_default_proxy(socks.SOCKS5, "localhost", 9050)
socket.socket = socks.socksocket
import requests
res = requests.get(url)
response = res.content
print(response)
from subprocess import check_call
check_call(["killall","-HUP", "tor"])
res = requests.get(url)
response = res.content
print(response)
In [2]: paste
url = 'http://my-ip.heroku.com'
import socks
import socket
socks.set_default_proxy(socks.SOCKS5, "localhost", 9050)
socket.socket = socks.socksocket
import requests
res = requests.get(url)
response = res.content
print(response)
from subprocess import check_call
check_call(["killall","-HUP", "tor"])
res = requests.get(url)
response = res.content
print(response)
## -- End pasted text --
94.242....
95.130....
Post a Comment for "Ip Remains Unchanged"