Created
March 24, 2017 19:12
-
-
Save invalidusrname/d389270838c39d2ec5c187ad1577c26d to your computer and use it in GitHub Desktop.
AT Spots
This file contains hidden or 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
| require 'open-uri' | |
| require 'nokogiri' | |
| url = 'http://www.summitpost.org/appalachian-trail-mileage-chart/593282' | |
| css = 'noformat table' | |
| doc = Nokogiri::HTML(open(url)) | |
| table = doc.css(css).detect { |e| e.text.include? 'Davenport' } | |
| rows = table.css('tr') | |
| first_row = rows.shift | |
| data = rows.collect do |row| | |
| row.css('td').collect { |e| e.text.to_s.gsub(',', '').strip } | |
| end | |
| data.each { |row| puts row * ',' }; nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment