Skip to content

Instantly share code, notes, and snippets.

@ezefranca
Created March 13, 2023 20:29
Show Gist options
  • Save ezefranca/46c655e42e72162897a86d2a4d3e9271 to your computer and use it in GitHub Desktop.
Save ezefranca/46c655e42e72162897a86d2a4d3e9271 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
Encoding.default_external = 'UTF-8'
query = params['query'] || 'banana'
page = (params['page'] || 0).to_i
url = "https://www.elcorteingles.pt/supermercado/pesquisar/" + (page > 0 ? "#{page}" : "") + "?term=#{query}&search=text"
document = Nokogiri::HTML(open(url, read_timeout: 30))
{
query: query,
url: url,
document: document
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment