//* 选择文档中的所有元素,无论名称如何。
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import json
import httplib
import re
import requests
from lxml import etree
import StringIO
import time
import datetime
import hashlib
import sys
reload(sys)
import io
res='<tr><td><a href="browse.jsp?JMSDestination=Consumer.xgmxt.VirtualTopic.HX.CashDetection">Consumer.xgmxt.VirtualTopic.HX.CashDetection</a></td><td>0</td>'
print type(res)
s=requests.session()
user='admin'
passwd='xx(xx'
myurl='http://%s:%s@2.2.24.5:8161/admin/queues.jsp' %(user,passwd)
print myurl
res1=s.get(myurl)
res2= res1.content
print type(res2)
#<tr><td><a href="browse.jsp?JMSDestination=Consumer.xdxt.VirtualTopic.ECIF.FTPACIMerger">Consumer.xdxt.VirtualTopic.ECIF.FTPACIMerger</a></td><td>0</td><td>41</td><td>0</td><td>0</td><td>
print dir(etree)
htmlEmt=etree.HTML(res2)
print dir(htmlEmt)
# time.sleep(100)
result1=htmlEmt.xpath('//*')
# result2=htmlEmt.xpath('//tr/td/')
print '----------------------------------------'
print result1
i=0
for x in result1:
if x.text :
if re.search("Consumer.",x.text) :
print result1[i].text
print result1[i+1].text
print result1[i + 2].text
print result1[i + 3].text
i=i+1
C:Python27python.exe C:/Users/tlcb/PycharmProjects/untitled/httprequest/pt4.py
Consumer.nbms.VirtualTopic.ECIF.FTPACIMerger
0
1
0
Consumer.zfdl.VirtualTopic.HX.JieGua
0
10
0
Consumer.xgmxt.VirtualTopic.HX.CashDetection
0
36
0
Consumer.datahub.VirtualTopic.XDXT.ChargeOff
0
1
351252
Process finished with exit code 0
<tr>
<td><a href="browse.jsp?JMSDestination=Consumer.xgmxt.VirtualTopic.HX.CashDetection">
Consumer.xgmxt.VirtualTopic.HX.CashDetection</a></td>
<td>0</td>
<td>36</td>
<td>0</td>
<td>0</td>
<td>