久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

python中PyQuery庫用法分享

瀏覽:4日期:2022-06-29 17:09:59

PyQuery庫就是python中的一個解析庫。作用十分強大,使用上也是相當?shù)撵`活,能夠實現(xiàn)初始化字符串、初始化 HTML 文件、初始化請求響應等多種場景,另外,本身中的CSS選擇器,也是經(jīng)常被大家使用的對象,結合以上的大致內容總結,接下來,我們一起詳細的了解使用內容。

安裝:

>>> pip3 install pyquery

引用方法:

from pyquery import PyQuery as pq

CSS選擇器:

from pyquery import PyQuery as pqhtml = ’’’<div id='container'><ul class='list'><li class='item-0'>first item</li><li class='item-1'><a href='http://www.baoyu77737.com/bcjs/link2.html' rel='external nofollow' >second item</a></li><li class='item-0 active'><a href='http://www.baoyu77737.com/bcjs/link3.html' rel='external nofollow' ><span class='bold'>third item</span></a></li><li class='item-1 active'><a href='http://www.baoyu77737.com/bcjs/link4.html' rel='external nofollow' >fourth item</a></li><li class='item-0'><a href='http://www.baoyu77737.com/bcjs/link5.html' rel='external nofollow' >fifth item</a></li></ul></div>’’’doc=pq(html)print(doc('#container .list li'))

輸出結果:

python中PyQuery庫用法分享

到此這篇關于python中PyQuery庫用法分享的文章就介紹到這了,更多相關python中PyQuery庫是什么內容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網(wǎng)!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 天柱县| 大庆市| 石景山区| 依安县| 上林县| 漯河市| 靖西县| 宁津县| 芷江| 泾阳县| 百色市| 常熟市| 观塘区| 安图县| 修文县| 运城市| 黄石市| 会东县| 波密县| 穆棱市| 昌乐县| 蒲江县| 裕民县| 敦煌市| 新巴尔虎右旗| 临漳县| 曲阳县| 霸州市| 台北市| 和田市| 甘孜| 曲麻莱县| 鄄城县| 绥棱县| 乌兰浩特市| 淅川县| 津南区| 赫章县| 蓬莱市| 巴林左旗| 邢台县|