首页IT科技python库介绍(python中PyQuery库是什么?)

python库介绍(python中PyQuery库是什么?)

时间2025-09-19 00:05:00分类IT科技浏览6323
导读:本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。...

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

安装:

>>>pip3installpyquery

引用方法:

frompyqueryimportPyQueryaspq

CSS选择器:

frompyqueryimportPyQueryaspq html= <divid="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> </div> doc=pq(html) print(doc("#container.listli"))

输出结果:

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

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
百度收录提交网站后多久收录(百度收录网站要多久?揭秘SEO中的“魔法时刻”)