Created
September 20, 2017 19:05
-
-
Save ornerymoose/8e828ad525757ead1b8016d173689441 to your computer and use it in GitHub Desktop.
if i remove rows on localhost:3000 via jquery, those removed rows aren't removed when generating the CSV. Why?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_csv | |
url = "http://localhost:3000" | |
doc = Nokogiri::HTML(open(url, :allow_redirections => :safe)) | |
csv = CSV.open("#{Rails.root}/public/collections-output.csv", 'w',{:col_sep => ","}) | |
csv << ['HEADERS HERE'] | |
doc.xpath('//table/tbody/tr').each do |row| | |
tarray = [] | |
row.xpath('td').each do |cell| | |
tarray << cell.text | |
end | |
csv << tarray | |
end | |
csv.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment