久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Python 中進行類似 jquery 的 HTML 解析?

jquery-like HTML parsing in Python?(在 Python 中進行類似 jquery 的 HTML 解析?)
本文介紹了在 Python 中進行類似 jquery 的 HTML 解析?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是否有任何 Python 庫可以讓我解析類似于 jQuery 的 HTML 文檔?

Is there any Python library that allows me to parse an HTML document similar to what jQuery does?

即我希望能夠使用 CSS 選擇器語法 從文檔中抓取任意一組節點,讀取它們的內容/屬性等.

i.e. I'd like to be able to use CSS selectors syntax to grab an arbitrary set of nodes from the document, read their content/attributes, etc.

我以前使用過的唯一 Python HTML 解析庫是 BeautifulSoup,盡管它很好,但我一直認為如果我有可用的 jQuery 語法,我的解析會更快.:D

The only Python HTML parsing lib I've used before was BeautifulSoup, and even though it's fine I keep thinking it would be faster to do my parsing if I had jQuery syntax available. :D

推薦答案

如果你精通BeautifulSoup,您只需將 soupselect 添加到您的庫中.
Soupselect 是 BeautifulSoup 的 CSS 選擇器擴展.

If you are fluent with BeautifulSoup, you could just add soupselect to your libs.
Soupselect is a CSS selector extension for BeautifulSoup.

用法:

from bs4 import BeautifulSoup as Soup
from soupselect import select
import urllib
soup = Soup(urllib.urlopen('http://slashdot.org/'))
select(soup, 'div.title h3')

    [<h3><span><a href='//science.slashdot.org/'>Science</a>:</span></h3>,
     <h3><a href='//slashdot.org/articles/07/02/28/0120220.shtml'>Star Trek</h3>,
    ..]

這篇關于在 Python 中進行類似 jquery 的 HTML 解析?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 久久久久国产精品一区二区 | 亚洲在线电影 | 波多野结衣精品在线 | av免费在线观看网站 | 免费观看www| 99视频在线免费观看 | 免费一级欧美在线观看视频 | 国产精品久久久久久久久久三级 | 免费黄色片在线观看 | 四虎影院新网址 | 免费视频一区二区 | 欧美亚洲国产一区二区三区 | 美女天天干天天操 | 99热热热热 | 少妇黄色 | 亚洲精品乱码久久久久久蜜桃91 | 国产一区二区免费在线 | 91亚洲一区| 中文字幕免费视频 | 日韩一级二级片 | 欧美日韩三区 | 殴美黄色录像 | 欧美在线国产精品 | 欧美综合国产精品久久丁香 | 久色视频在线 | 久久久久国产成人精品亚洲午夜 | 欧美亚洲成人网 | xxxxxx国产| av免费网址 | 日本三级电影免费观看 | 国产精品成人一区二区 | 国产亚洲一区二区在线观看 | 亚洲九色| 成人一区在线观看 | 中文字幕第一页在线 | 成人免费视频一区 | av免费网站在线观看 | 亚洲视频一区 | 男插女下体视频 | 精品国产99 | 亚洲一区视频在线播放 |