日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

python linux 打印机,Python抓取打印机硒鼓和组件剩余量的爬虫

發(fā)布時(shí)間:2023/12/10 linux 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python linux 打印机,Python抓取打印机硒鼓和组件剩余量的爬虫 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

#coding:utf-8

import re,os,urllib,string

def getHtml(url):

page = urllib.urlopen(url)

html = page.read()

return html

def getData(html):

cartridge = r'Black Print Cartridge??(.+?%)'

car = re.compile(cartridge)

Cartridge = re.findall(car,html)

rekit = r'Maintenance Kit??(.+?%)'

kit = re.compile(rekit)

Kit = re.findall(kit,html)

print "Cartridge=%s" % Cartridge,

print "Kit=%s" % Kit

def getData_TFNRCPRT02(html):

cartridge = r'??(.+?%)'

car = re.compile(cartridge)

Cartridge = re.findall(car,html)

print "Cartridge=%s" % Cartridge

def IpStatus(ip):

Status = os.system("ping" + " " + ip)

return Status

def getIp(url):

getIp = r'http://(.+?)/'

GetIp = re.compile(getIp)

IpAddress = re.findall(GetIp,url)

ip = ''.join(IpAddress)

return ip

UrlDir = {

'http://10.132.160.171/hp/device/this.LCDispatcher' : 'LegalPrt04',

'http://10.132.160.172/hp/device/this.LCDispatcher' : 'LegalPrt05',

'http://10.153.24.177/hp/device/this.LCDispatcher' ?: 'SzPrt11' ? ,

'http://10.153.24.172/hp/device/this.LCDispatcher' ?: 'SzPrt13' ? ,

'http://10.153.26.179/hp/device/this.LCDispatcher' ?: 'SzPrt14' ? ,

'http://10.186.65.156/hp/device/this.LCDispatcher' ?: 'TfnrcPrt01',

'http://10.186.65.101/' : 'TfnrcPrt3390',

'http://10.153.25.200/' : 'SzPrt16'

}

for url in UrlDir:

ip = getIp(url)

Status = IpStatus(ip)

if Status == 0:

if url == 'http://10.186.65.101/':

html = getHtml(url)

print UrlDir[url]+":",

getData_TFNRCPRT02(html)

elif url == 'http://10.153.25.200/':

print "SZPRT16 is OK"

else:

html = getHtml(url)

print UrlDir[url]+":",

getData(html)

else:

print UrlDir[url] + ":"+"Ping fail"

總結(jié)

以上是生活随笔為你收集整理的python linux 打印机,Python抓取打印机硒鼓和组件剩余量的爬虫的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。