add matemat scraper

This commit is contained in:
Astro 2020-04-04 04:11:14 +02:00
parent 548d117934
commit 5f0540def3
2 changed files with 32 additions and 0 deletions

View File

@ -26,4 +26,5 @@ in {
xerox = wrapScript "xerox" ./xerox/scrape.rb;
luftdaten = wrapScript "luftdaten" ./luftdaten/scrape.rb;
fhem = wrapScript "fhem" ./fhem/scrape.rb;
matemat = wrapScript "matemat" ./matemat/scrape.rb;
}

31
matemat/scrape.rb Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
require 'influxdb'
points = []
data = JSON.parse open("http://matemat.hq.c3d2.de/statistics.json", :http_basic_authentication => ['k-ot', 'k-ot']).read()
points.push({
series: 'statistics',
values: data,
})
data = JSON.parse open("http://matemat.hq.c3d2.de/summary.json", :http_basic_authentication => ['k-ot', 'k-ot']).read()
data.each do |d|
points.push({
series: 'summary',
tags: {
name: d["name"],
},
values: {
price: d["price"],
value: d["value"],
volume: d["volume"],
}
})
end
db = InfluxDB::Client.new(url: "http://grafana.hq.c3d2.de:8086/matemat")
db.write_points(points, 'm')