试图让 Tor 使用 Python,但一直拒绝连接.? [英] Trying to get Tor to work with Python, but keep getting connection refused.?

查看:79
本文介绍了试图让 Tor 使用 Python,但一直拒绝连接.?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图让 Tor 与 Python 一起工作,但我一直在碰壁.我根本无法让任何示例起作用.这是 Stackoverflow

I've been trying to get Tor to work with Python, but I've been hitting a brick wall. I simply can't get any of the examples to work. Here is one from Stackoverflow

import urllib2
proxy  = urllib2.ProxyHandler({'http':'127.0.0.1:8118'})
opener = urllib2.build_opener(proxy)
print opener.open('http://check.torproject.org/').read()

我已经安装了 Tor,它在浏览 Aurora 时运行良好.但是运行这个 python 脚本我得到

I've installed Tor and it works fine while browsing through Aurora. However running this python script I get

Traceback (most recent call last):
File "/home/x/Tor.py", line 4, in <module>
  print opener.open('http://check.torproject.org/').read()
File "/usr/lib/python2.6/urllib2.py", line 391, in open
  response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
  '_open', req)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
  result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1161, in http_open
  return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.6/urllib2.py", line 1136, in do_open
  raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>

我在网上搜索过,但找不到有类似问题的人.我是否遗漏了一些非常明显的东西?!

I've searched the web, but been unable to find people with simiair problems. Am I missing something totally obvious?!

推荐答案

我在 http://blog.databigbang.com/distributed-scraping-with-multiple-tor-circuits/

希望有帮助.

这篇关于试图让 Tor 使用 Python,但一直拒绝连接.?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆