Skip to content

Instantly share code, notes, and snippets.

@oliveira-andre
Last active September 30, 2019 17:24
Show Gist options
  • Select an option

  • Save oliveira-andre/8c6f0b2fac10555a37cd1ec917dc2df7 to your computer and use it in GitHub Desktop.

Select an option

Save oliveira-andre/8c6f0b2fac10555a37cd1ec917dc2df7 to your computer and use it in GitHub Desktop.
scrapping games linux in nuuvem
#! /usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
page = Nokogiri::HTML(open('https://www.nuuvem.com/catalog/price/under_l/sort/bestselling/sort-mode/desc'))
games = []
page.css('.product-card--grid').each do |dados|
json = {
title: '',
price: '',
img: '',
link: ''
}
#insert the title of the game
dados.css('.product-title').each do |title|
json[:title] = title.content
end
#insert the link of the game
dados.css('.product-card--wrapper').map do |a|
json[:link] = a['href']
end
#insert the image of the game
dados.css('.product-img img').map do |img|
json[:img] = img[:src]
end
#insert the price of the game
dados.css('.product-price--val').map do |price|
json[:price] = price.content.strip
end
games << json
end
games.each do |game|
puts "
|Game: #{game[:title]}|
| - Preço: #{game[:price]}|
| - Link: #{game[:link]}|
| ------------------------------------------------|"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment