Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6200143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:18:48+00:00 2026-05-24T04:18:48+00:00

I am writing a Ruby script which automatically crawls websites for data analysis, and

  • 0

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 – as many of you will know, by editing the torrc configuration file it is possible to specify the exit node and hence the country from which the actual request will originate.

When I do this manually, e.g. by editing the torrc file to use an Argentinian server, then disconnecting Tor using Vidalia, reconnecting Vidalia, and then rerunning the request, it works fine. However, I want to automate this process entirely, and do it as efficiently as possible. Tor is written in C, and I’d like to avoid taking apart its entire source code for this. Any idea of what’s the easiest way to automate the whole process using only Ruby?

Also, if I’m missing something and there’s a simpler alternative to this whole ordeal, let me know.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:18:49+00:00Added an answer on May 24, 2026 at 4:18 am

    Please take a look at Tor control protocol. You can control circuits using telnet.
    http://thesprawl.org/memdump/?entry=8

    To switch to a new circuit wich switches to a new endpoint:

      require 'net/telnet'
    
      def switch_endpoint
        localhost = Net::Telnet::new("Host" => "localhost", "Port" => "9051", "Timeout" => 10, "Prompt" => /250 OK\n/)
        localhost.cmd('AUTHENTICATE ""') { |c| print c; throw "Cannot authenticate to Tor" if c != "250 OK\n" }
        localhost.cmd('signal NEWNYM') { |c| print c; throw "Cannot switch Tor to new route" if c != "250 OK\n" }
        localhost.close
      end
    

    Be aware of the delay to make a new circuit, may take couple seconds, so you’d better add a delay in the code, or check if your address has changed by calling some remote IP detection site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Ruby script and would like to use a n-ary tree data
I want to load a data structure into a Ruby script which maps a
I'm very new to Ruby. I've recently finished writing a simple script, which uses
I am writing a testing script using Ruby and Rails. I have to validate
I am writing a Ruby 1.8.7 script which has to request really large XML
I'm writing a ruby bootstrapping script for a school project, and part of this
I am writing a Ruby app at the moment which is going to search
I'm writing a Ruby library which has a module with a bunch of classes
I am about to be writing a Ruby on Rails app which will use
I'm writing a rake script and would like to detect (using Ruby rather than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.