Updating parsing according to status page
This commit is contained in:
parent
ea4d25f597
commit
3dd845d333
1 changed files with 4 additions and 4 deletions
|
@ -20,16 +20,16 @@ COLOR_INFOS = {
|
||||||
COLORS = COLOR_INFOS.keys()
|
COLORS = COLOR_INFOS.keys()
|
||||||
|
|
||||||
CONS_CLASS_BLOCK = {
|
CONS_CLASS_BLOCK = {
|
||||||
color: re.compile(".*consumable-block-"+color.capitalize() +".*")
|
color: re.compile(".*gauge "+color.capitalize() +".*")
|
||||||
for color in COLORS
|
for color in COLORS
|
||||||
}
|
}
|
||||||
|
|
||||||
def ffindconsomable(color, raw):
|
def ffindconsomable(color, raw):
|
||||||
"""Retrouve la couleur `color` dans raw"""
|
"""Retrouve la couleur `color` dans raw"""
|
||||||
couleur=raw.findAll('div', attrs={"class":CONS_CLASS_BLOCK[color]})
|
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_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]
|
couleur_tambour=couleur_tambour.split('%')[0]
|
||||||
try:
|
try:
|
||||||
couleur_tambour=re.sub('[^\.0-9]', '', couleur_tambour.decode())
|
couleur_tambour=re.sub('[^\.0-9]', '', couleur_tambour.decode())
|
||||||
|
@ -56,7 +56,7 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
page = requests.get(URL, verify=CA)
|
page = requests.get(URL, verify=CA)
|
||||||
raw=BeautifulSoup.BeautifulSoup(page.text)
|
raw=BeautifulSoup.BeautifulSoup(page.text)
|
||||||
|
|
||||||
for color in COLORS:
|
for color in COLORS:
|
||||||
toner, tambour = ffindconsomable(color, raw)
|
toner, tambour = ffindconsomable(color, raw)
|
||||||
print('{}_toner.value {}'.format(color, toner))
|
print('{}_toner.value {}'.format(color, toner))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue