Scraping HTML with Nokogiri and Ruby
In this tutorial I’ll be using Ruby language and its popular library Nokogiri. So, if you do not have Ruby language and Nokogiri installed in your system then you can use Repl.it.
Repl.it allows users to write code and build apps and websites using a browser.
Let’s get started!!
What is Nokogiri?
Nokogiri is an open source software library to parse HTML and XML in Ruby. It is one of the most downloaded Ruby gems, having been downloaded over 300 million times from the rubygems.org repository.
I think that’s enough, right? Now let’s get our hands dirty with the code!
Opening a Web Page as HTML with Nokogiri and open-uri
Before we write our actual code, we need to have couple libraries included in our code in order to scrape the HTML
require 'nokogiri'
require 'open-uri'
These two lines will give us functionality of Nokogiri and Open-uri in our file.