Skip to content

Instantly share code, notes, and snippets.

@cicloid
Last active November 10, 2016 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cicloid/cd8d1da4463f48f3093a to your computer and use it in GitHub Desktop.
Save cicloid/cd8d1da4463f48f3093a to your computer and use it in GitHub Desktop.
Simple sinew script to extract prices
# 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