A
A
Alexey2019-07-31 14:24:53
Ruby on Rails
Alexey, 2019-07-31 14:24:53

Need to parse products from a category, does not pass through an array of products url?

You need to parse the products from the category and go through them and collect information about each into a file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oh_shi, 2019-07-31
@chelo_vek

require 'open-uri'
require 'nokogiri'

doc = Nokogiri::HTML(open('https://www.petsonic.com/snacks-huesos-para-perros/'))
doc.xpath('.//a[@class="product-name"]/@href').each do |url|
  puts url
  page = Nokogiri::HTML(open(url))
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question