标签:text 数据 class esc mst 一个 pre tin ring
from lxml import etree
doubanhtml = ‘‘‘‘‘‘
doc = etree.fromstring(doubanhtml)
for eachbook in doc.xpath(‘//dl/dd‘):
bookname = eachbook.xpath(‘a/text()‘)[0]
bookurl = eachbook.xpath(‘a/@href‘)[0]
pub = eachbook.xpath(‘div[@class="desc"]/text()‘)[0]
rate = eachbook.xpath(‘div[@class="rating"]/span[@class="rating_nums"]/text()‘)[0]
print bookname,bookurl,pub,rate
python 第二周(第八天) 我的python成长记 一个月搞定python数据挖掘!(14)
标签:text 数据 class esc mst 一个 pre tin ring
原文地址:http://www.cnblogs.com/yugengde/p/7258228.html