当前位置: 首页 > 图灵资讯 > 行业资讯> python中PyQuery库是什么?

python中PyQuery库是什么?

来源:图灵python
时间: 2024-09-18 19:13:38

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

安装:

>>>pip3installpyquery

引用方法:

frompyqueryimportPyQueryaspq

CSS选择器:

frompyqueryimportPyQueryaspq
html='''
<pid="container">
<ulclass="list">
<liclass="item-0">firstitem</li>
<liclass="item-1"><ahref="link2.html">seconditem</a></li>
<liclass="item-0active"><ahref="link3.html"><spanclass="bold">thirditem</span></a></li>
<liclass="item-1active"><ahref="link4.html">fourthitem</a></li>
<liclass="item-0"><ahref="link5.html">fifthitem</a></li>
</ul>
</p>
'''
doc=pq(html)
print(doc("#container.listli"))

输出结果:

好了,以上就是PyQuery库的所有使用方法,感兴趣的朋友可以多了解学习~

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

上一篇:

python中pdb模块怎么用?

下一篇:

返回列表