国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python爬蟲PyQuery庫基本用法入門教程

2020-02-15 22:41:05
字體:
來源:轉載
供稿:網友

本文實例講述了Python爬蟲PyQuery庫基本用法。分享給大家供大家參考,具體如下:

PyQuery庫也是一個非常強大又靈活的網頁解析庫,如果你有前端開發經驗的,都應該接觸過jQuery,那么PyQuery就是你非常絕佳的選擇,PyQuery 是 Python 仿照 jQuery 的嚴格實現。語法與 jQuery 幾乎完全相同,所以不用再去費心去記一些奇怪的方法了。

官網地址:http://pyquery.readthedocs.io/en/latest/

jQuery參考文檔: http://jquery.cuishifeng.cn/

1、字符串的初始化

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

<div>
    <ul>
         <li class="item-0">first item</li>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 英德市| 芒康县| 辽中县| 永靖县| 内黄县| 永福县| 陇南市| 会泽县| 柘荣县| 新化县| 锦州市| 万安县| 阿巴嘎旗| 乌什县| 西畴县| 湖北省| 商丘市| 澄江县| 夏邑县| 兴海县| 枣庄市| 比如县| 正定县| 射阳县| 伊宁市| 长春市| 苍山县| 织金县| 宜宾县| 隆回县| 江口县| 云霄县| 长葛市| 潢川县| 博客| 新源县| 洮南市| 彰武县| 涡阳县| 曲靖市| 浦县|