本帖最后由 Vastsea 于 2020-5-18 20:46 编辑 ip1 = ['10.0.3.12','10.0.55.20','10.0.3.18','10.0.70.18','10.0.3.15','10.0.70.24']
ip2 = ['10.0.3.30','10.0.3.31','10.0.3.32','10.0.65.18','10.0.70.22','10.0.65.11','10.0.45.11']
for i in ip1:
url1 = "http://" + i + "/web/guest/cn/websys/status/getUnificationCounter.cgi"
req = requests.get(url1)
html = req.text
bs = BeautifulSoup(html,"html.parser")
trs = bs.select('tr.staticProp')[1].get_text()
n = 2
r = str(n)
n = n + 1
ws['a' + r] = i
ws['b' + r] = trs
wb.save("c:\\New folder\\11.xlsx")
for i in ip2:
url2 = "http://" + i + "/SSI/info_configuration.htm"
req = requests.get(url2)
html = req.text
bs = BeautifulSoup(html,"html.parser")
trs = bs.select('tr')[20].get_text()
n = 8
r = str(n)
n = n + 1
ws['a' + r] = i
ws['b' + r] = trs
wb.save("c:\\New folder\\11.xlsx")
这样可以吗? |