Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Loop through each .olpOffer (product listing) and gather content from various elements
- parse_page.css('.olpOffer').each do |a|
- if a.css('.olpSellerName img').empty?
- seller = a.css('.olpSellerName').text.strip
- else
- seller = a.css('.olpSellerName img').attr('alt').value
- end
- offer_price = a.css('.olpOfferPrice').text.strip
- prime = a.css('.supersaver').text.strip
- shipping_info = a.css('.olpShippingInfo').text.strip.squeeze(" ").gsub!(/(n)/, '')
- condition = a.css('.olpCondition').text.strip
- fba = "FBA" unless a.css('.olpBadge').empty?
- #Push data from each product listing into array
- arr.push(seller,offer_price,prime,shipping_info,condition,fba)
- end
- #Need to make each product listing's data begin in new row [HELP!!]
- CSV.open("file.csv", "wb") do |csv|
- csv << ["Seller", "Price", "Prime", "Shipping", "Condition", "FBA"]
- end
- end
Add Comment
Please, Sign In to add comment