Created
August 29, 2015 19:02
-
-
Save codealchemy/5a47671095b39beeba89 to your computer and use it in GitHub Desktop.
Pulls each image from html content to clean urls to match to uploaded page attachments in NationBuilder
This file contains hidden or 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
| require 'csv' | |
| require 'nokogiri' | |
| CSV.open('slug_with_image.csv', 'w') do |csv| | |
| CSV.foreach('blog_file.csv', headers: true) do |row| | |
| content_html = Nokogiri::HTML(row['content']) | |
| content_html.css('img').each do |img| | |
| csv << [img['src'], row['slug']] | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment