xpath速度确实快....
bs_info = bs(restext, 'lxml')
selector = lxml.etree.HTML(restext)
s1 = time.time()
rank=selector.xpath('//*[@class="pic"]//em/text()')
e1 = time.time()
s2 = time.time()
rank = [
x.find("em").text for x in bs_info.find_all(
'div', {
'class': 'pic'})]
e2 = time.time()
print(e1-s1)
print(e2-s2)
print(rank)
exit()
bs4和xpath比较
猜你喜欢
转载自www.cnblogs.com/swortect/p/12424837.html
今日推荐
周排行