tor

Python3 - Requests with Sock5 proxy

若如初见. 提交于 2019-12-03 17:20:57
问题 Is there a way to use sock5 proxy to use TOR with requests? I know that requests only use http proxy... import requests r = requests.get('http://www.google.com',proxies= my_proxy) 回答1: You can use socks, socket modules import socks import socket from urllib import request socks.set_default_proxy(socks.SOCKS5, "localhost", 9050) socket.socket = socks.socksocket r = request.urlopen('http://icanhazip.com') print(r.read()) # check ips The socks package can be installed from multiple packages

tor tutorial “speaking to russia” stuck at 45 - 50%

时光总嘲笑我的痴心妄想 提交于 2019-12-03 16:34:18
when I try to follow the tutorial ( https://stem.torproject.org/tutorials/to_russia_with_love.html ) about how to start up Tor I keep getting stuck at 45% and sometimes at 50%. I am using windows 8, python 3.4 and the LiClipse ide. [1mStarting Tor: [0m [34mApr 26 12:47:21.000 [notice] Bootstrapped 0%: Starting[0m [34mApr 26 12:47:21.000 [notice] Bootstrapped 45%: Asking for relay descriptors[0m [34mApr 26 13:04:00.000 [notice] Bootstrapped 50%: Loading relay descriptors[0m The script looks like this, the change I have made myself here is to use requests library instead of urllib to rquest data

Selenium WebDriver + Tor as proxy with Stem?

为君一笑 提交于 2019-12-03 15:46:50
I need to confirm If Stem can be used to launch a Tor process that exposes 127.0.0.1:port, then use it on selenium scripts as proxy (SOCKS). I'm using Python 3.4.2 , Stem 1.3.0, and Tor (tor-win32-tor-0.2.5.10 expert bundle) on Windows. This piece of code works with a standard SOCKS proxy. from selenium import webdriver from selenium.webdriver.firefox.firefox_profile import FirefoxProfile profile = FirefoxProfile() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.socks', '127.0.0.1') profile.set_preference('network.proxy.socks_port', 9000) driver =

Python ssh using Tor proxy

僤鯓⒐⒋嵵緔 提交于 2019-12-03 13:46:13
I would like to be able to send data through Tor when I use ssh from Python scripts. Tor works as expected when I use an OpenSSH client to manually ssh to the host. This is my ssh config file. I use connect-proxy with ProxyCommand to route the connections through Tor (again, this works fine via a standard OpenSSH client): host host user user hostname host.domain.com CheckHostIP no Compression yes Protocol 2 ProxyCommand connect-proxy -S localhost:9050 %h %p I have this Python test script: import paraproxy import paramiko conf = paramiko.SSHConfig() conf.parse(open('/home/user/.ssh/config'))

using tor with scrapy framework

放肆的年华 提交于 2019-12-03 13:33:59
问题 I am trying to crawl website, which is sophisticated enough to stop bots, I mean it is permitting only a few requests, after that Scrapy hangs. Question 1: is there a way, if Scrapy hangs I can restart my crawling process from the same point. To get rid of this problem, I wrote my settings file like this BOT_NAME = 'MOZILLA' BOT_VERSION = '7.0' SPIDER_MODULES = ['yp.spiders'] NEWSPIDER_MODULE = 'yp.spiders' DEFAULT_ITEM_CLASS = 'yp.items.YpItem' USER_AGENT = '%s/%s' % (BOT_NAME, BOT_VERSION)

Why Tor cant access localhost pages

99封情书 提交于 2019-12-03 11:45:45
I have Tor running and a python script to get web pages: socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050) socket.socket = socks.socksocket print urllib2.urlopen(URL).read() However, if the URL is http://localhost/some_page.html I get the following error: raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])]) TypeError: __init__() takes exactly 2 arguments (3 given) Can someone explain to me what exactly happens? Thank you. It is the way protocol is designed. When you send a request, it is transported to another machine on Internet with Socks5 envelope. So actual request

How do I get the Tor exit node IP address over the control port?

余生长醉 提交于 2019-12-03 11:40:46
问题 I want to monitor the status of running Tor instances. I am already able to get information via a TCP connection to the control ports. E.g. "GETINFO stream-status" returns data, but I am not able to determine the IP address of the currently chosen exit node. It would be possible to simply request something like whatismyip.org, but that is too slow and does not scale well. So what is the best way to get the exit node IP address of a Tor connection? 回答1: This is a great question! Here's a short

Ruby, Tor and Net::HTTP::Proxy

断了今生、忘了曾经 提交于 2019-12-03 10:10:19
问题 My apologies in advance if this is a noobish doubt: I want to use a proxy in my Ruby code to fetch a few web pages. And I want to be sneaky about it! So I am using Tor. I have Tor running, and I am able to use Net::HTTP.get(uri) as usual. But I can't figure out how to use Net::HTTP::Proxy to fetch the uri. I also can't figure out how using Tor will help make my fetches anonymous. Any help is greatly appreciated. Please don't just add a link to the ruby-doc page for Net::HTTP::Proxy. If I had

Controlling Tor client with Ruby

☆樱花仙子☆ 提交于 2019-12-03 09:51:58
问题 I am writing a Ruby script which automatically crawls websites for data analysis, and now I have a requirement which is fairly complicated: I have to be able to simulate access from a variety of countries, about 20 different ones. The website will contain different information depending on the IP location, so the only way to get it done is to request it from a server which is actually in that country. Since I don't want to buy servers in each of those 20 countries, I chose to give Tor a try -

Getting Tor ControlPort to work

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have installed Tor to run as a service on my windows machine and I am trying to make requests in python through the Stem package. In my torrc file I have specified ControlPort as 9051 and set a HashedControlPassword. When I run netstat, I see that Tor is running on localhost:9050 but there is nothing listening to port 9051. As a result, when I try to connect to the ControlPort in python: Controller.from_port(port=9051) results in a [Errno 10061] No connection could be made because the target machine actively refused it I've tried