每次访问网站时,我都试图使用tor获取新的IP:
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, '127.0.0.1', 9151, True)
socket.socket = socks.socksocket
import urllib2
print urllib2.urlopen("http://almien.co.uk/m/tools/net/ip/").read()
我也试过91509050端口。
我不断得到:
socks.ProxyConnectionError: Error connecting to SOCKS4 proxy 127.0.0.1:9151: [Errno 61] Connection refused
使用stem包与Tor交互。官方网站有许多不同案例的教程,例如:
https://stem.torproject.org/tutorials/to_russia_with_love.html