tor

Using Tor proxy with scrapy

拜拜、爱过 提交于 2019-12-03 07:54:51
问题 I need help setting up Tor in Ubuntu and to use it within scrapy framework. I did some research and found out this guide: class RetryChangeProxyMiddleware(RetryMiddleware): def _retry(self, request, reason, spider): log.msg('Changing proxy') tn = telnetlib.Telnet('127.0.0.1', 9051) tn.read_until("Escape character is '^]'.", 2) tn.write('AUTHENTICATE "267765"\r\n') tn.read_until("250 OK", 2) tn.write("signal NEWNYM\r\n") tn.read_until("250 OK", 2) tn.write("quit\r\n") tn.close() time.sleep(3)

How to use Tor control protocol in C#?

大兔子大兔子 提交于 2019-12-03 07:20:21
问题 I'm trying to send commands to the Tor control port programmatically to make it refresh the chain. I haven't been able to find any examples in C#, and my solution's not working. The request times out. I have the service running, and I can see it listening on the control port. public string Refresh() { TcpClient client = new TcpClient("localhost", 9051); string response = string.Empty; string authenticate = MakeTcpRequest("AUTHENTICATE\r\n", client); if (authenticate.Equals("250")) { response

Python3 - Requests with Sock5 proxy

血红的双手。 提交于 2019-12-03 07:08:30
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) Eugene Alkhouski 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 which are forks of socksipy . One particular one that also works on Python3 is PySocks . You

using tor with scrapy framework

帅比萌擦擦* 提交于 2019-12-03 03:31:49
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) DOWNLOAD_DELAY = 0.25 DUPEFILTER=True COOKIES_ENABLED=False RANDOMIZE_DOWNLOAD_DELAY=True SCHEDULER

Trying to get Tor to work with Python, but keep getting connection refused.?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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() 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

How can I make a Pull request using TortoiseGit

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In TortoiseGit When I hit Right Click -> Push, OK, Give it User/Pass then after that there is a Create Pull request button giving it a Start, URL, End. I am clicking, but nothing happens. The Pull requests (0) is shown in my repo. And one other thing, How can I make a pull request and then update it as necessary using the same software (TortoiseGit) 回答1: The doc mentions : After pushing your changes to a (public) repository, you just provide other people the URL of your repository and the name of the branch or the revision id. E.g.: git:/

How to make git work to push commits to GitHub via tor?

跟風遠走 提交于 2019-12-03 02:42:58
So, GitHub is now officially banned by Russian Government and Rospotrebnadzor. I used GitHub to create free software and share it, and it's important part of my life. Today I've installed Tor on Arch Linux and now I'm able to browse GitHub and other banned sites. I tried to make git work via Tor but without success. Here is what I did: git config --global http.proxy localhost:9050 git config --global https.proxy localhost:9050 But when I try to push, I get error 501 : fatal: unable to access ' https://X@github.com/X/X.git/ ': Received HTTP code 501 from proxy after CONNECT So, 501 means 'not

Mass string replace in python?

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Say I have a string that looks like this: str = "The &yquick &cbrown &bfox &Yjumps over the &ulazy dog" You'll notice a lot of locations in the string where there is an ampersand, followed by a character (such as "&y" and "&c"). I need to replace these characters with an appropriate value that I have in a dictionary, like so: dict = {"&y":"\033[0;30m", "&c":"\033[0;31m", "&b":"\033[0;32m", "&Y":"\033[0;33m", "&u":"\033[0;34m"} What is the fastest way to do this? I could manually find all the ampersands, then loop through the dictionary to

Tor browser, new IP not working?

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use tor browser, and get a new IP address each URL I visit in python. I am able to open an instance of selenium running the tor browser, but how can I request a new IP every website I visit? binary = '/Applications/TorBrowser.app/Contents/MacOS/firefox' if os.path.exists(binary) is False: raise ValueError("The binary path to Tor firefox does not exist.") firefox_binary = FirefoxBinary(binary) browser = None def get_browser(binary=None): browser = webdriver.Firefox(firefox_binary=binary) return browser if __name__ == "__main__"

How to control tor, when use tor proxy

匿名 (未验证) 提交于 2019-12-03 02:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to connect to a resource using a tor, changing identity. But after the first connection attempt to change identity causes an error. Code: import urllib2, socks, socket from stem import Signal from stem.control import Controller def newI(): with Controller.from_port(port=9051) as controller: controller.authenticate() controller.signal(Signal.NEWNYM) newI() socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050) socket.socket = socks.socksocket headers = {'User-Agent': 'Mozilla/3.0 (x86 [en] Windows NT 5.1; Sun)'} req =