A select function similar to soups.
See original GitHub issueIs your feature request related to a problem? Please describe. It’s great to be able to run find and then find within the initial result, but it seems more readable to be able to find based on CSS selectors.
Describe the solution you’d like
selector = '.foo img.bar'
soup.select(selector) # this would return any img item with the class "bar" inside of an object with the class "foo"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Use of select function in beautiful soup - ProjectPro
Beautiful Soup provides the .select() method which is used to run a CSS selector against a parsed document and return all the matching...
Read more >Beautifulsoup : Difference between .find() and .select()
1 Answer 1 · select finds multiple instances and returns a list, find finds the first, so they don't do the same thing....
Read more >Beautiful Soup 4.9.0 documentation - Crummy
Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide...
Read more >Top 5 Beautiful Soup Functions That Will Make Your Life Easier
BeautifulSoup (,) creates a data structure representing a parsed HTML or XML document. Most of the methods you'll call on a BeautifulSoup object ......
Read more >Beautiful Soup Documentation — Beautiful Soup 4.4.0 ...
select () method which uses SoupSieve to run a CSS selector against a parsed document and return all the matching elements. Tag has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I came here to request CSS selector support too - every scraper I’ve written in the past decade has worked using CSS selectors and I honestly can’t imagine scraping without them.
I wrote the first library that added selector support to BeautifulSoup (before it was a built-in feature) - the implementation wasn’t too complicated, you’re welcome to borrow from it if it looks useful: https://github.com/simonw/soupselect
My offer here isn’t for your to depend on soupselect - which is 14 years old and never saw a release on PyPI. It’s for you to copy and paste over the code from that, clean it up and incorporate it into Gazpacho. The key implementation is only 100 lines of Python.