-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to extract individual values raw #3
Comments
I don't think CSS selection can select base on attributes though. Do you want to give another example instead? |
If you just want to raw CSS selection value, The work around is to use one
e.g.,
It's not perfect, but |
The issue with using <html>
<head></head>
<body>
...
<div>
<a href="/files/plugin-name/download?version=1.25">1.25</a>
</div>
...
</body>
</html> I want to be able to retrieve only the value of href with nothing else, as well as innerText of that anchor. |
Perhaps an alternative would be adding a |
Gotya. Lee me think it over... |
Happy to raise a PR if needed |
Uhm... I gave a careful thought about it, and was about to turn it down, because my believe in the "Unix philosophy" -- Write programs that
I.e., the attributes selection is impossible with CSS thus should be out of the scope of $ echo '<p><a href="/home">some url</a></p>' | cascadia -i -o -c 'p' -p 'ATag=a' | sed 1d
some url I.e., it'd against my principle to complicate my code base for something so simple to solve. However, I do see a need in your request, and you offered a PR. So I'm OK with the PR, iff you are doing the correct way -- i.e., starting from If that doesn't deter you, then go ahead. :-) Thx for your contribution. |
closed for lack of activity, please reopen if there is more input... |
You can do it using pup.
|
Just stumbled onto this issue as I was attempting to extract all of the curl --silent https://example.com/somethingwithscripts | cascadia --in --out --css 'html > head > script' --piece url='attr[src]' I also tried various variations of this none of which seemed to work: curl --silent https://example.com/somethingwithscripts | cascadia --in --out --css 'html > head > script' --piece url='attr[src]:script'
curl --silent https://example.com/somethingwithscripts | cascadia --in --out --css 'html > head > script' --piece url='attr[src]:*'
curl --silent https://example.com/somethingwithscripts | cascadia --in --out --css 'html > head' --piece url='attr[src]:script' Yet with
|
Hmm... please try giving a minimal reproducible example. Else I won't be able to guess what the problem is. |
Also, you didn't say which version you're using. Are you using the v1.2.7? Sorry, trying to rush out some reply before getting back to my burning issue at hand... |
<html>
<head>
<script src="foo.js"></script>
<script src="bar.js"></script>
<script src="baz.js"></script>
</head>
</html> ⇒ pbpaste | cascadia --in --out --css 'html > head > script' --piece url='attr[src]'
url
⇒ pbpaste | cascadia --in --out --css 'html > head > script' --piece url='attr[src]:script'
url
⇒ pbpaste | cascadia --in --out --css 'html > head' --piece url='attr[src]:script'
url
foo.js
Expected outcome:
|
Indeed, it looks like a bug. Will look into it when I have some time. Meanwhile, CC: @himcc, I've replicated problem @0xdevalias reported, seems to be logic problem with attr selection. Do you have some time to look into it please? Hope the final interface would be: |
While it would sort of be a breaking change, in a sense it feels like the The initial thing I would have expected/tried was just being able to use standard CSS attribute selector syntax within That way the ⇒ pbpaste | cascadia --in --out --css 'html > head > script' --piece url='[src]'
⇒ pbpaste | cascadia --in --out --css 'html > head' --piece url='script[src]'
# etc Skimming the codebase, the following areas look like they would be relevant/related to these changes:
|
@suntong @himcc I haven't looked too deeply at the code/tested this assumption, but from a quick skim I noticed that what appears to be the section handling Lines 165 to 200 in 4b56cde
Whereas the seemingly non- Lines 127 to 165 in 4b56cde
Based on that, and the fact that in my above (Though personally, I still think it would be useful to simplify and improve the |
Yep, I thought so too. Thanks for investating.
That's a brilliant idea. I've been searching for CSS Attribute selectors before many times, but all conclusings had been that it is not supported. Yeah, I fully agree with you that we should use the CSS Attribute selectors syntax instead. |
Ops,
I didn't look into the url closely, but having check it out again just now, I found that the Will think it over... |
@suntong Yup, that is how it works in normal CSS selector usage, and is how it would need to work (and just how it does work I believe) in the So basically:
So then combined, you could use these like I described above:
|
Another alternative would be to re-consider how
They have:
Personally I don't think I'm pretty sure the So it basically seems to just leave the Though personally I like the idea of keeping the CSS selector |
Thanks for the great input. Make sense. |
@suntong No worries, I appreciate it :) |
Another source of 'prior art', |
Awesome! Will have to check it out once a new release is made! Thanks :) |
something like this:
The text was updated successfully, but these errors were encountered: