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

  • Home
  • SEARCH
  • 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 8082187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:00:10+00:00 2026-06-05T17:00:10+00:00

I want to update an erb.html page in rails with information from a webscraping

  • 0

I want to update an erb.html page in rails with information from a webscraping script I wrote, but I don’t want the page to have to refresh every time new info comes in.

I don’t know where to put the background script, how rails will invoke it, etc.

How do I do this?

  • 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-05T17:00:14+00:00Added an answer on June 5, 2026 at 5:00 pm

    There are a number of ways to achieve your desired result in terms of construction but in the end you are going to have use Javascript and an AJAX call as there is no other way to update the content on your page with the scraped data.

    Here’s how I use AJAX and screen-scraping for RoR:

    application.js

    In our application JS file we listen on a field for when it is changed (the user inputs a web url or some kind of data) and then we make an AJAX call to our scraper (url set up in Routes.rb later) and our data is returned in JSON format (when the success trigger of AJAX is called) which we loop through and display the scraped data in two fields that are named in a similar format as the key of our JSON key, value pairs.

    $('#item_url').live('change', function() {          
         $.ajax({
                url: "/scrape/siteandnum", 
                data: {item_url: document.getElementById('item_url').value},             
                dataType: 'json', 
                success: function(data) {                                                               
                        $.each(data, function(key, value) {                        
                            document.forms['new_qued_item'].elements['qued_item_' + key].value = value
                        });         
                    }
                });
    }); 
    

    qued_items_controller.rb

    In our controller we have a method which is the Ruby scrape code. It takes in the params of the item_url (passed in from the data of the AJAX call) — in this example it takes in an eBay auction URL and gives us the eBay site domain and the item number.

    def scrape_site_and_num
        url = params[:item_url] 
        itemnumber = url.match(/\d{12}/)[0].to_i 
        site = url.match(/ebay.(co.uk|com|de|fr|it|ca)/)[0]
    
        render :json => {'itemnumber' => itemnumber, 'site' => site}
    end 
    

    routes.rb

    Of course we have to have a route so that the AJAX call knows where to access our scrape method.

      get "scrape/siteandnum/" => "qued_items#scrape_site_and_num"
    

    So there you have it. Using this method any kind of data can be entered and a “behind-the-scenes” Ruby method will process the user input and come back with some screen-scraped data without the page ever reloading!

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

Sidebar

Related Questions

I have Categories controller and in layout _menu.html.erb I want to output all categories
I have the following form in my edit.html.erb page <%= form_for(@device) do |f| %>
What I want: Update all new commits from server with my local repository in
i have ios application with xcdatamodeld, i want update some data so need a
I have developed a windows forms c# application, i just want update items in
I want to update the lastlogin column value .i wrote the code like this
I want to update Paypal Order status and add tracking number using API. but
The problem: I have a collection of people, I want to have a revise.html
new rails user here. I have a rails project that I want to accept
All I want to do is update a text field on my page with

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.