jeudi 22 janvier 2015

Ruby Webscraping through pages


Vote count:

0




Webscraper Trying to iterate through each page on site Here is what i am trying to use but not working


I am wanting to make sure the code will grab the very last page. Currently the page displays pages 1 through 20 but typically the # of pages exceeds 20



require 'nokogiri'
require 'open-uri'
require 'csv'


# Scrape the max number of pages and store in max_page variable
page_numbers = []
page_numbers.keep_if {|x| x.to_i > 0}.each do |line|
page_numbers << line.text
end

max_page = page_numbers.max

max_page.times do |i|


url = "http://ift.tt/1CkhDxV"

# Parse the page with Nokogiri
page = Nokogiri::HTML(open(url))


asked 52 secs ago







Ruby Webscraping through pages

Aucun commentaire:

Enregistrer un commentaire