def lxml_test():
url = "http://www.caixunzz.com"
req = urllib2.Request(url=url)
resp = urllib2.urlopen(req)
#print resp.read()
'''
parse_body=html.fromstring(resp.read())
href=parse_body.xpath('//a[@class="label"]/@href')
print href
#not working from above
'''
tree = etree.HTML(resp.read())
href = tree.xpath('//a[@class="label"]/@href')
#print href.tag
for i in href:
#print html.tostring(i)
#print type(i)
print i
print type(href)
#not working yet
评论列表
文章目录