last day (29 days later) » 

3:05 PM
Hi, sorry to ping you randomly. I had a query regarding future developments of bs4. Are there any plans to allow selection by :contains on any element, or would that fall over spectactularly. Something like soup.select('*:contains("something")')
 
 
7 hours later…
9:37 PM
You can totally do that already. It often isn't very helpful as you'll get a hit for every parent up the chain. Remember that :contains() searches all the descendants under an element for text that matches.
 
With the syntax I show?
I was pondering the question you answered here: stackoverflow.com/questions/56792630/…
 
```
from bs4 import BeautifulSoup
import requests

html = """
<div>
<p><span>text</span></p>
</div>
"""
soup = BeautifulSoup(html, 'html.parser')
print(soup.select('*:contains("text")'))
Ugh. I guess you can't press enter when doing multi-lined stuff.
 
nope...
 
Anyways, the output of above looked like this:
So where you considering a way to search for multiple text options with :contains()?
If so, that is doable.
 
yes.... I assumed I used an Or syntax of x:contains, x:contains
I guess I messed up something in how I typed it
 
9:45 PM
Nope
 
.......
:-)
 
So :contains() was abandoned forever ago now by those in charge of the CSS spec, but I figured, if they had kept it, it would have evolved.
 
mmhmmm
 
So I added the ability to add multiple search items separated by commas.
:contains('word', 'text')
I forget which version of soupsieve it is in.
 
awesome sauce!
Presumably still in the latest?
 
9:48 PM
Yes, if you have the latest, you have that ability.
 
Invalid character '"' position 11
line 1:
*:contains("something","something else")
 
They've been pushing to allow mutliple selectors in :not() and others, and so I figured if :contains() had been managed under them today, it would have made sense.
You may be on the latest bs4, but maybe not soupsieve.
 
Aha
 
bs4 requires >= 1.2, so it won't always update soupsieve if it fulfills the requirment.
 
I have 1.8
 
9:51 PM
Yup, update it
I think it is on 1.9.2
 
I really should do that. All these things I try playing around with and don't work as expected
You have been really helpful so thank you so much.
 
The way I convinced the bs4 author to let me take over CSS support was to do it as a separate library so he didn't have to support it anymore. The original implementation was not done by the author and was a big headache for him as it had a lot of bugs.
So the coupling isn't as tight as I would have liked.
 
Yeah.... I am so much more impressed by latest
 
It was a side project that spiraled out of control. I was trying to filter HTML for spell checking with Aspell, and the filters sucked. So I picked up bs4 and the CSS selectors sucked. Then I sunk way too much time in writing my own :/.
 
lol....
I'm just seeing how I get conda to upgrade soupsieve
Wonder if request for install will reject as installed or offer upgrade?
hummm it offers 1.8
 
9:58 PM
Hmm, I know they have a repo that manages the latest: github.com/conda-forge/soupsieve-feedstock.
I don't really use conda though :shrug:
 
Don't blame you
Except for async it's ok and useful to have everything lumped together
given how many machines I seem to rotate over
 
I know it is popular with those that do data sciences.
 
Smarter people would write a set-up script
 
It's python for dummies - like me..... nice and easy off the shelf until you wanna do something more advanced.
Then it all goes poof in a cloud of thread already running... block .....
 
10:02 PM
Yeah, I like the pip install -U soupsieve to upgrade with plain old pip.
I thought you could also use pip in conda though? Or is that not true?
 
Yeah.... I have though I am sure I read somewhere that one should use conda to manage the process as it def checks the environmental dependencies
Anyway.... I ran pip instead and guess what?
Successfully installed soupsieve-1.9.2
Yeah !!!!!!!!!
 
Nice. Good 'ol pip saves the day.
 
🕺
Really appreciate your time.
I'm off to explore my new toy!
Have a nice evening
 
You too!
 
thanks
 

  last day (29 days later) »