SHARE
TWEET

Untitled

Kuzminov Mar 8th, 2020 (edited) 283 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'faker'
  2. require 'csv'
  3.  
  4. page = 'путь страницы'
  5. parse_page = Nokogiri::HTML(page)
  6. all_element = parse_page.xpath('//div[contains(@class, "Все элемены в одном li")]')
  7.  
  8. CSV.open('price_file.csv', 'w+') do |csv|
  9.   csv << ['Название и размер', 'Цена', 'Изображение']
  10.  
  11.   all_element.each do |object|
  12.     csv << [
  13.       object.xpath('//div["Название и размер"]'),
  14.       object.xpath('//div["Цена"]'),
  15.       object.xpath('//div["Изображение"]'),
  16.     ]
  17.   end
  18. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top