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 8229487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:48:41+00:00 2026-06-07T16:48:41+00:00

I’m writing an application to crawl some websites and scrape data from them. I’m

  • 0

I’m writing an application to crawl some websites and scrape data from them. I’m using Ruby, Curl and Nokogiri to do this. In most cases it’s straightforward and I only need to ping a URL and parse the HTML data. The setup works perfectly fine.

However, in some scenarios, the websites retrieve data based on user input on some radio buttons. This invokes some JavaScript which fetches some more data from the server. The generated URL and posted data is determined by JavaScript code.

Is it possible to use:

  1. A JavaScript library along with this setup which would be able to determine execute the JavaScript in the HTML page for me?

  2. Apart from using a different library, is there some integration or a way for the HTML and JS libraries to communicate? For instance if a button is clicked, Nokogiri needs to call JavaScript and then the JavaScript needs to update Nokogiri.

In case my approach doesn’t seem the best, what would your suggestion be to build a crawler + scraper on the web using Ruby.

EDIT: Looks like point 1 is possible using therubyrace as it embeds the V8 engine in your code, but is there an alternative to 2?

  • 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-06-07T16:48:44+00:00Added an answer on June 7, 2026 at 4:48 pm

    You are looking for Watir which runs a real browser and allows you to perform every action you can think of on a web page. There’s a similar project called Selenium.

    You can even use Watir with a so-called ‘headless’ browser on a linux machine.

    Watir headless example

    Suppose we have this HTML:

    <p id="hello">Hello from HTML</p>
    

    and this Javascript:

    document.getElementById('hello').innerHTML = 'Hello from JavaScript';
    

    (Demo: http://jsbin.com/ivihur)

    and you wanted to get the dynamically inserted text. First, you need a Linux box with xvfb and firefox installed, for example on Ubuntu do:

    $ apt-get install xvfb firefox
    

    You will also need the watir-webdriver and headless gems so go ahead and install them as well:

    $ gem install watir-webdriver headless
    

    Then you can read the dynamic content from the page with something like this:

    require 'rubygems'
    require 'watir-webdriver'
    require 'headless'
    
    headless = Headless.new
    headless.start
    browser = Watir::Browser.new
    
    browser.goto 'http://jsbin.com/ivihur' # our example
    el = browser.element :css => '#hello'
    puts el.text
    
    browser.close
    headless.destroy
    

    If everything went right, this will output:

    Hello from JavaScript
    

    I know this runs a browser in the background as well, but it’s the easiest solution to your problem i could come up with. It will take quite a while to start the browser, but subsequent requests are quite fast. (Running goto and then fetching the dynamic text above multiple times took about 0.5 sec for each request on my Rackspace Cloud Server).

    Source: http://watirwebdriver.com/headless/

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.