Running python script with TOR

戏子无情 提交于 2019-12-06 07:31:33

It was possible with this using given answers:

import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
socket.socket = socks.socksocket
import urllib2

print(urllib2.urlopen("http://www.ifconfig.me/ip").read())

But I am surprised is it possible to change tor's ip address with each new request???

J-16 SDiZ

Have you read the error message? It say "501 Tor is not an HTTP Proxy".

It is a SOCKS proxy, not a HTTP proxy. Try use it like so: How can I use a SOCKS 4/5 proxy with urllib2? and Python urllib over TOR?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!