安装PyQuery库:
>>> 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库的全部使用方式了,感兴趣的小伙伴可以多了解学习下哦~
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试