Skip to content

Instantly share code, notes, and snippets.

@Camvillard
Last active April 28, 2019 20:38
Show Gist options
  • Save Camvillard/0cc4d7b5f5093ae02e43a221eb18fa6b to your computer and use it in GitHub Desktop.
Save Camvillard/0cc4d7b5f5093ae02e43a221eb18fa6b to your computer and use it in GitHub Desktop.
Scrape HTML . using open-uri & nokogiri gems
url = "http://www.letscookfrench.com/recipes/find-recipe.aspx?s=chocolate"
html_file = open(url).read
html_doc = Nokogiri.HTML(html_file)
html_doc.search('.m_titre_resultat a').each do |element|
puts element.text.strip
puts element.attribute('href').value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment