Last active
November 10, 2016 19:05
-
-
Save cicloid/cd8d1da4463f48f3093a to your computer and use it in GitHub Desktop.
Simple sinew script to extract prices
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
# Very naive approach to scrap pricing using Sinew https://github.com/gurgeous/sinew/ | |
get 'http://fuelgaugereport.aaa.com/import/display.php?lt=state&ls=' | |
noko.css("tr").drop(1).each do |item| | |
# pull out the stuff we care about using nokogiri | |
row = { } | |
row[:state] = item.css("a").text | |
# Ultra naive way to extract pricing | |
row[:regular] = item.css(".price")[0].text | |
row[:mid] = item.css(".price")[1].text | |
row[:premium] = item.css(".price")[2].text | |
row[:diesel] = item.css(".price")[3].text | |
# append a row to the csv | |
csv_emit row | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment