require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open('https://www.w3.org/')) doc.xpath('//a').each do |a| puts a['href'] end