doc = Nokogiri::HTML(html)
showings = []
doc.css('.ok-product').each do |showing|
showing_id = showing['data-cart-id'].to_i
price = showing.at_css('.ok-product__price-main').text.gsub(/[\u0440\u0443\u0431.]/, '').strip
showings.push(
id: showing_id,
price: price
)
end
CSV.open("file.csv", "wb") do |csv|
csv << showings
end
我得到的數據以CSV單元格A1:
{:id=>26999, :price=>"395,00"},"{:id=>26963, :price=>""254,00""}"...
需要打破數據進入細胞並刪除不必要的符號。
你叫什麼細胞? – yoones
現在全部在A1。但我需要:A1,B1,A2,B2,A3,B3 ... – Mamom
請閱讀「[mcve]」。我們需要最小的輸入數據來證明問題。什麼是'html'?沒有這個你的問題沒有多大意義。 –