Skip to content

Instantly share code, notes, and snippets.

@solars
Created May 20, 2011 12:18
Show Gist options
  • Save solars/982799 to your computer and use it in GitHub Desktop.
Save solars/982799 to your computer and use it in GitHub Desktop.
# Task: fetch html, replace img src
doc = Nokogiri::HTML(html)
doc.xpath('//img').each do |image|
image_url = image.attributes['src']
# fetch correct url
image.attributes['src'].value = <new url>
end
doc.to_html # still contains old url?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment