ruby nokogiri
# install nokogiri gem
gem instal nokogiri
require 'open-uri'
require 'nokogiri'
url = 'https://www.lewagon.com'
html = URI.open(url)
doc = Nokogiri::HTML.parse(html)
# getting what you want with CSS selectors
doc.search(css_selector)
The output of #search
is a Nokogiri nodeset
elements = doc.search('.my-class')
elements.class #=> Nokogiri::XML::NodeSet
Getting a the url from a link:
elements[0].attribute('href').value