Extending CSS selectors in BeautifulSoup

前端 未结 2 1019
失恋的感觉
失恋的感觉 2021-01-17 10:35

The Question:

BeautifulSoup provides a very limited support for CSS selectors. For instance, the only supported pseudo-class i

2条回答
  •  清歌不尽
    2021-01-17 11:22

    Officially, Beautifulsoup doesn't support all the CSS selectors.

    If python is not the only choice, i strongly recommend JSoup (the java equivalent of this). It supports all the CSS selectors.

    • It is open source (MIT license)
    • Syntax is easy
    • Supports all the css selectors
    • Can span multiple threads too to scale up
    • Rich API support in java to store in DBs. So, it is easy to integrate.

    The other alternate way if you still want to stick with python, make it a jython implementation.

    http://jsoup.org/

    https://github.com/jhy/jsoup/

提交回复
热议问题