diff --git a/README.md b/README.md index e3d43ed..08963cc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ # gas-station-exporter -scrape gas prices from clever-tanken.de and export them as prometheus metrics \ No newline at end of file +Scrapes gas prices from [https://clever-tanken.de](clever-tanken.de ) and export them as prometheus metrics + +## Requirements + +`pip install lxml beautifulsoup4` + +## Config + +Set your station IDs in list in `gas-stations-exporter.py`. + +**Hint** DonĀ“t scrape with higher intervalls due to blocking based on requests! + +## Usage + +to start: `python3 gas-station-exporter.py` + +to get metrics: `curl http://127.0.0.1:9100/metrics` + +Example metrics: + +``` +gas_expoter_duration_seconds_sum 53 +gas_exporter_request_count 1 +gas_bft_Hauptstr91_77839_Lichtenau_Diesel 2.129 +gas_bft_Hauptstr91_77839_Lichtenau_SuperE10 1.969 +gas_bft_Hauptstr91_77839_Lichtenau_SuperE5 1.999 +gas_bft_Hauptstr91_77839_Lichtenau_SuperPlus 2.079 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_Diesel 2.039 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_SuperE10 1.789 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_SuperE5 1.849 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_ExcelliumSuperPlus 2.019 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_LKWDiesel 2.039 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_AdBluePKW 1.849 +gas_TotalEnergies_AmRheinubergang_77866_Freistett_AdBlueLKW 1.799 +gas_Sonstige_Hauptstr_77866_Rheinau_Diesel 2.029 +gas_Sonstige_Hauptstr_77866_Rheinau_SuperE10 1.779 +gas_Sonstige_Hauptstr_77866_Rheinau_SuperE5 1.839 +gas_bft_Hauptstr2_77871_Renchen_Diesel 2.069 +gas_bft_Hauptstr2_77871_Renchen_SuperE10 1.779 +gas_bft_Hauptstr2_77871_Renchen_SuperE5 1.839 +gas_AVIA_Bahnhofstr1_72275_Alpirsbach_Diesel 2.079 +gas_AVIA_Bahnhofstr1_72275_Alpirsbach_SuperE10 1.869 +gas_AVIA_Bahnhofstr1_72275_Alpirsbach_SuperE5 1.929 +gas_AVIA_Bahnhofstr1_72275_Alpirsbach_SuperPlus 2.009 +gas_bft_FreudenstadterStr75_72275_Alpirsbach_Diesel 2.069 +gas_bft_FreudenstadterStr75_72275_Alpirsbach_SuperE10 1.899 +gas_bft_FreudenstadterStr75_72275_Alpirsbach_SuperE5 1.919 +gas_AVIA_Hauptstr73_77761_Schiltach_Diesel 2.079 +gas_AVIA_Hauptstr73_77761_Schiltach_SuperE10 1.869 +gas_AVIA_Hauptstr73_77761_Schiltach_SuperE5 1.929 +gas_AVIA_Hauptstr73_77761_Schiltach_SuperPlus 2.009 +gas_AVIA_Hauptstr73_77761_Schiltach_LPG 1.099 +``` + diff --git a/gas-station-exporter.py b/gas-station-exporter.py index 95c4f3d..b009b01 100644 --- a/gas-station-exporter.py +++ b/gas-station-exporter.py @@ -2,10 +2,7 @@ # -*- coding: utf-8 -*- """ Author: Hendrik Schutter, mail@hendrikschutter.com Date of creation: 2022/10/23 - Date of last modification: 2022/10/23 - - pip install lxml beautifulsoup4 - + Date of last modification: 2022/10/26 """ from http.server import BaseHTTPRequestHandler, HTTPServer @@ -16,8 +13,8 @@ from urllib.parse import urlsplit, parse_qs from random import randrange import station_scraper -hostName = "10.10.3.1" -serverPort = 29816 +hostName = "127.0.0.1" +serverPort = 9100 exporter_prefix = "gas_" stations_ids = (20153, 21907, 183433, 159416, 30856, 16362, 12634)