Created
May 29, 2015 02:39
-
-
Save dalehamel/8535ac5b5c1ec1833cd5 to your computer and use it in GitHub Desktop.
on demand price scraper
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
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