question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A select function similar to soups.

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Oct 10, 2020

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

0reactions
simonwcommented, Oct 11, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found