简体   繁体   中英

When using Nokogiri with RoR, I'm not getting all the information from the webpage, not sure why?

This is my Scraper Controller

class ScraperController < ApplicationController

    def getinformation
        require 'open-uri'
        require 'nokogiri'
        @information = Nokogiri::HTML(open('https://ibotta.com/rebates'))
    end

end

And this is a webpage of the information that I'm getting from nokogiri https://rails-tutorial2-chriscma.c9users.io/scraper/getinformation

I'm not getting any of the product names, and I'm not sure why?

The page you're trying to scrape is dynamically generated by executing javascript, so you won't be able to use nokogiri to download the content. It looks like the offers on the page are loaded from https://ibotta.com/web_v1/offers.json , but this isn't accessible directly. Therefore, I think you'll need to use something which can execute javascript like selenium / phantomjs / chrome headless / watir etc in order to load the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM