16

how can I configure Ruby web client to request web pages using Tor ?

1
  • 1
    I'd like to know how to do this also. Commented Dec 24, 2009 at 17:47

4 Answers 4

14

I had to use this Gem http://socksify.rubyforge.org/ then I was able to do something like this

TCPSocket::socks_server = "127.0.0.1" TCPSocket::socks_port = 9050 reply = Net::HTTP.get URI.parse("www.google.com") 

Obviously with the Tor proxy running.

Sign up to request clarification or add additional context in comments.

2 Comments

So in order to use Tor through Ruby you have to have the Tor client downloaded and running?
Yes this won't work unless the client is running. Also verify its SOCKs port is set properly. When I downloaded the latest Tor browser my port was 9150 (as opposed to 9050 which is listed above).
3

I think it's like specifying proxy server for your HTTP connection. I don't know how it works in Ruby. But it will not be different from configuring browsers. Just set proxy server setting to 127.0.0.1:8118.

Comments

2

Created a Gem, maybe can help others: https://github.com/brunogh/tor_requests

Comments

1

You just need to work with the Proxy class. As Ivan says above, get Tor running then point Net::HTTP.Proxy at the correct localhost address and you're golden.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.