From d93045ab74f1a9fbd2a360fd24ca624c7cc2c62f Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 5 Sep 2023 23:21:34 +0200 Subject: [PATCH] fhem, freifunk, impfee, matemat: use open-uri properly --- fhem/scrape.rb | 2 +- freifunk_node/scrape.rb | 2 +- impfee/scrape.rb | 4 ++-- matemat/scrape.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fhem/scrape.rb b/fhem/scrape.rb index d684efd..05a082f 100644 --- a/fhem/scrape.rb +++ b/fhem/scrape.rb @@ -10,7 +10,7 @@ PASSWORD = ARGV[2] points = [] -doc = Nokogiri::HTML open("https://#{HOST}/fhem?room=all", :http_basic_authentication => [USER, PASSWORD]) +doc = Nokogiri::HTML URI::open("https://#{HOST}/fhem?room=all", :http_basic_authentication => [USER, PASSWORD]) doc.css('.roomoverview tr').each do |row| name = row.css('.col1').text current = row.css('.col2').text diff --git a/freifunk_node/scrape.rb b/freifunk_node/scrape.rb index 8760e67..b93d7c2 100644 --- a/freifunk_node/scrape.rb +++ b/freifunk_node/scrape.rb @@ -7,7 +7,7 @@ require 'influxdb' HOST = ARGV[0] -data = JSON.parse open("http://#{HOST}/sysinfo-json.cgi").read() +data = JSON.parse URI::open("http://#{HOST}/sysinfo-json.cgi").read() $node_id = data['data']['common']['node'] $node_name = URI::decode(data['data']['contact']['name']) diff --git a/impfee/scrape.rb b/impfee/scrape.rb index e5770ec..d8115fa 100644 --- a/impfee/scrape.rb +++ b/impfee/scrape.rb @@ -5,13 +5,13 @@ require 'json' require 'influxdb' # https://www.countee.ch/app/de/counter/impfee/_iz_sachsen -data = JSON.parse open("https://www.startupuniverse.ch/api/1.1/de/counters/getAll/_iz_sachsen").read() +data = JSON.parse URI::open("https://www.startupuniverse.ch/api/1.1/de/counters/getAll/_iz_sachsen").read() points = [] data['response']['data'].each do |id, iz| next if iz['closed'] != 0 sum = iz['counteritems'].map { |item| item['val'] }.sum - + points.push({ series: "iz", tags: { diff --git a/matemat/scrape.rb b/matemat/scrape.rb index d49ec91..6c98b3a 100644 --- a/matemat/scrape.rb +++ b/matemat/scrape.rb @@ -10,13 +10,13 @@ PASSWORD = ARGV[2] points = [] -data = JSON.parse open("https://#{HOST}/statistics.json", :http_basic_authentication => [USER, PASSWORD]).read() +data = JSON.parse URI::open("https://#{HOST}/statistics.json", :http_basic_authentication => [USER, PASSWORD]).read() points.push({ series: 'statistics', values: data.map { |(n, i)| [n, i.to_i] }, }) -data = JSON.parse open("http://#{HOST}/summary.json", :http_basic_authentication => [USER, PASSWORD]).read() +data = JSON.parse URI::open("https://#{HOST}/summary.json", :http_basic_authentication => [USER, PASSWORD]).read() data.each do |d| points.push({ series: 'summary',