您好,欢迎来到要发发知识网。
搜索
您的当前位置:首页python中PyQuery库是什么?

python中PyQuery库是什么?

来源:要发发知识网

 

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

安装:

>>> pip3 install pyquery

引用方法:

from pyquery import PyQuery as pq

CSS选择器:

from pyquery import PyQuery as pq
html = '''
<div id="container">
<ul class="list">
<li class="item-0">first item</li>
<li class="item-1"><a href="link2.html">second item</a></li>
<li class="item-0 active"><a href="link3.html"><span class="bold">third item</span></a></li>
<li class="item-1 active"><a href="link4.html">fourth item</a></li>
<li class="item-0"><a href="link5.html">fifth item</a></li>
</ul>
</div>
'''
doc=pq(html)
print(doc("#container .list li"))

输出结果:

 

好啦,以上就是PyQuery库的全部使用方式了,感兴趣的小伙伴可以多了解学习下哦~

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

Copyright © 2019- net188.cn 版权所有 湘ICP备2022005869号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务