From 3dd845d33338dc43da09dfd30e7f8ff445e4e923 Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Tue, 29 Sep 2015 19:41:53 +0200 Subject: [PATCH] Updating parsing according to status page --- munin/consommables_hp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/munin/consommables_hp b/munin/consommables_hp index 39baec56..54b27270 100755 --- a/munin/consommables_hp +++ b/munin/consommables_hp @@ -20,16 +20,16 @@ COLOR_INFOS = { COLORS = COLOR_INFOS.keys() CONS_CLASS_BLOCK = { - color: re.compile(".*consumable-block-"+color.capitalize() +".*") + color: re.compile(".*gauge "+color.capitalize() +".*") for color in COLORS } def ffindconsomable(color, raw): """Retrouve la couleur `color` dans raw""" couleur=raw.findAll('div', attrs={"class":CONS_CLASS_BLOCK[color]}) - couleur_toner=couleur[0].findAll('p',attrs={"class":'data percentage'})[0].string + couleur_toner=couleur[0].findAll('span')[0].string couleur_toner=couleur_toner.split('%')[0] - couleur_tambour=couleur[1].findAll('p',attrs={"class":'data percentage'})[0].string + couleur_tambour=couleur[1].findAll('span')[0].string couleur_tambour=couleur_tambour.split('%')[0] try: couleur_tambour=re.sub('[^\.0-9]', '', couleur_tambour.decode()) @@ -56,7 +56,7 @@ if __name__ == '__main__': else: page = requests.get(URL, verify=CA) raw=BeautifulSoup.BeautifulSoup(page.text) - + for color in COLORS: toner, tambour = ffindconsomable(color, raw) print('{}_toner.value {}'.format(color, toner))