Skip to content

Instantly share code, notes, and snippets.

@dalehamel
Created May 29, 2015 02:39
Show Gist options
  • Save dalehamel/8535ac5b5c1ec1833cd5 to your computer and use it in GitHub Desktop.
Save dalehamel/8535ac5b5c1ec1833cd5 to your computer and use it in GitHub Desktop.
on demand price scraper
require 'net/http'
require 'json'
def getPrices(path)
uri = URI(path)
res = Net::HTTP.get_response(uri)
data = res.body.match(/.*callback\((.*)\);/).captures[0]
data = data.gsub(/(\w+):/,"\"\\1\":")
d = JSON.parse(data)
puts JSON.pretty_generate(d['config']['regions'])
end
getPrices('https://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js')
getPrices('https://a0.awsstatic.com/pricing/1/ec2/previous-generation/linux-od.min.js')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment