gistfile1.txt

# https://readysteadycode.com/howto-extract-data-from-html-with-ruby # Result: => { value: null, text: 'Please select an option' } # The excercise make a scanning of the page to get USA states and formatting them in a object to use in a select with vueJs require 'mechanize' mechanize = Mechanize.new page = mechanize.get('https://www.britannica.com/topic/List-of-nicknames-of-U-S-States-2130544') page.search('a.md-crosslink').each do |link| # puts link['href'] # puts link.text puts "{ value: '#{link.text}', text: '#{link.text}'}," end
Mechanize with ruby for do web scrapping

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.