6 PROXY
= 'http://127.0.0.1:8118'
7 USER_AGENT
= "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5"
9 proxy_handler
= urllib2
.ProxyHandler({'http': PROXY
})
10 req
= urllib2
.build_opener(proxy_handler
)
11 req
.add_headers
= [("User-Agent",USER_AGENT
)]
12 o
= req
.open( "http://checkip.dyndns.com/")
13 print "Tor proxy:" ,re
.findall("<body>(.*?)</body>",o
.read())[0]
18 AUTH_MSG
= "authenticate \n"
19 CHANGE_MSG
= "signal newnym \n"
21 sock
= socket
.socket(socket
.AF_INET
, socket
.SOCK_STREAM
)
22 sock
.connect((TOR_IP
, TOR_PORT
))