Last active
August 29, 2015 13:57
-
-
Save nickserv/9634511 to your computer and use it in GitHub Desktop.
A simple script that shows the text contents of any web page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: ruby web_cat.rb URL | |
require 'nokogiri' | |
require 'open-uri' | |
uri = ARGV[0] | |
doc = Nokogiri::HTML open uri | |
puts doc.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gets the text contents of the page as if you rendered it and removed all formatting, not the entire source code of the page. For example,
<b>Hello, world!</b>
would display asHello, world!
.