网络爬行。无法正确抓取数据

时间:2020-08-28 12:20:57

标签: ruby web-scraping web-crawler nokogiri open-uri

require 'open-uri'   
require 'nokogiri'    

url = "https://grofers.com/cn/grocery-staples/cid/16" 
response = open(url).read
parsed_data = Nokogiri::HTML(response)

results = []

content = parsed_data.css('.section-right').css('.products products--grid').each do |row|
  title = row.css('a.product__wrapper').text
  puts title

  results << content
end

0 个答案:

没有答案