got it ungzipping gzip stream and the get works
This commit is contained in:
parent
7ba4928770
commit
c3755a71d3
1 changed files with 13 additions and 2 deletions
|
@ -1,4 +1,6 @@
|
||||||
require 'rest-client'
|
require 'rest-client'
|
||||||
|
require 'zlib'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
class NvdDownloader
|
class NvdDownloader
|
||||||
attr_accessor :base_url, :years
|
attr_accessor :base_url, :years
|
||||||
|
@ -22,9 +24,18 @@ class NvdDownloader
|
||||||
years[year]
|
years[year]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def get(url)
|
def get(url)
|
||||||
|
r = RestClient.get "#{base_url}#{url}"
|
||||||
|
r.body if r.code == 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_gzip_stream(gzip_stream)
|
||||||
|
io_stream = StringIO.new(gzip_stream)
|
||||||
|
gz = Zlib::GzipReader.new(io_stream)
|
||||||
|
gz.read
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_json(json_string)
|
||||||
|
JSON.parse(json_string)
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue