通过 Tor 使用 Python 进行网页搜索时遇到困难
我在 OSX 10.5 上运行 python 2.5.1 和 Tor 0.2.2.34
我已经检查了 SOCKS 问题和 尝试让 Tor 与 Python 一起工作问题和Tor with Python问题并尝试了所有这些,以及上面,同时在后台运行 Tor,但没有一个真正起作用。如果我尝试“Tor with Python”方式(只是 urllib2),脚本可以工作,但是当通过 Python 以相同的方式在 Whatsmyip 页面上读取和打印源代码进行检查时,我的 IP 没有变化。
这是我试图通过 Tor 运行的脚本:(
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 8118)
socket.socket = socks.socksocket
import urllib2
web_page = "http://www.cartage.org.lb/en/themes/arts/architec/architecturalstructure/LookingforLiminality/LookingforLiminality.htm"
req = urllib2.Request(web_page)
response = urllib2.urlopen(req)
the_page = response.read()
matches = re.findall('Gianni Vattimo', the_page)
if len(matches) == 0:
print 'RESULTS!'
else:
print 'There were NO results!'
网页只是一个示例,而不是我的实际目标 obv。)
当我运行这个脚本时,它只是在终端中无限期地停滞。正如我所说,我尝试了不同的演绎,将端口更改为其他建议等,但没有任何效果。有什么建议或经过测试的修复吗?
谢谢。
I am running python 2.5.1 and Tor 0.2.2.34 on OSX 10.5
I have checked the SOCKS question and the Trying to get Tor to work with Python question and the Tor with Python question and have tried them all, and a combination of the above, while running Tor in the background and none have worked really. If I try the "Tor with Python" way (just urllib2) the script works, but my IP goes unchanged when checked by reading and printing the source code on a whatsmyip page in the same way through Python.
this is the script I'm trying to run through Tor:
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 8118)
socket.socket = socks.socksocket
import urllib2
web_page = "http://www.cartage.org.lb/en/themes/arts/architec/architecturalstructure/LookingforLiminality/LookingforLiminality.htm"
req = urllib2.Request(web_page)
response = urllib2.urlopen(req)
the_page = response.read()
matches = re.findall('Gianni Vattimo', the_page)
if len(matches) == 0:
print 'RESULTS!'
else:
print 'There were NO results!'
(the web page is just an example and not my actual target obv.)
When I run this script it just stalls in Terminal for an indefinite amount of time. As I said, I've tried different renditions, changing the port to other suggestions, etc, but nothing has worked. Any suggestions or tested fixes?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论