0
点赞
收藏
分享

微信扫一扫

pyquery的使用

小沙坨 2023-02-06 阅读 146


#coding=utf-8

from pyquery import PyQuery as pq

html = '''
<div class="shop">

<a class="shopname J_Mou>
<span class="dsrs">

<span class="dsr morethan"></span>

<span class="dsr morethan"></span>

<span class="dsr morethan"></span>

</span>
<span>天猫超市1</span>
<span>天猫超市2</span>
</a>
</div>



'''

#pyquery取出天猫超市1的两种方法

doc = pq(html)
print(doc('.shop').text())

for item in doc('span').items():
print(item.text())


举报

相关推荐

0 条评论