Text and attribute pseudo-selectors
See original GitHub issuePre W3C, CSS Selectors only select nodes within XML documents, however they do not select text nodes or attribute values. Frameworks like parsel
(scrapy) have successfully implemented pseudo-selectors like ::text
or ::attr
which allow you to do that.
Given soupsieve
’s current architecture, is it possible to add such selectors?
For reference https://parsel.readthedocs.io/en/latest/usage.html#extensions-to-css-selectors
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Pseudo-classes - CSS: Cascading Style Sheets | MDN
Matches an input element that is displaying placeholder text. For example, it will match the placeholder attribute in the <input> and <textarea> ...
Read more >CSS Pseudo-classes - W3Schools
What are Pseudo-classes? A pseudo-class is used to define a special state of an element. For example, it can be used to: Style...
Read more >Meet the Pseudo Class Selectors | CSS-Tricks
Text -related pseudo class selectors / elements ... ::first-letter – Selects the first letter of the text in the element. Typical use: drop...
Read more >CSS Selectors - Attribute, Pseudo & Combinator Selectors
In today's video we are going to explore CSS selectors. We'll start with the basics, going over element, class and ID selectors, ...
Read more >Complex Selectors - Learn to Code Advanced HTML & CSS
The class selector identifies an element based on its class attribute value, ... padding: 6px 12px; text-decoration: none; } a:hover { color: #ff7b29;...
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
While it is certainly possible to implement this. I think I’m going to pass. It adds unnecessary complexity and inefficiency for very little gain. I’m yet to hear how this is more helpful than just calling
text
on the returned elements.While I’m open to a conversation on this, as things stand now, there are no plans to implement these.
@gir-bot remove P: maybe @gir-bot add S: wontfix
Currently, I have intentionally not implemented any pseudo elements, just pseudo classes. Beautiful soup can access such on the returned element.
It is most likely possible, but I would need to decide whether that is a path that I want to go down. If I did go down this path, I would probably support no more than
::text
and maybe::attr
.This would of course add a bit more complexity as pseudo elements can’t be processed in certain cases etc.
I won’t say no, but I’ll leave it as a maybe. If I do this, it may have to wait until I have the time to spend as this would be a fairly big addition.
@gir-bot remove S: triage @gir-bot add T: feature, P: maybe