Last active
July 21, 2022 21:12
-
-
Save knbknb/31b20db2357b41622d692eeb17e8eaaf to your computer and use it in GitHub Desktop.
XPath: common queries with curl and xidel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# attribute values | |
curl -sL "${url}${urlparams}" \ | |
| xidel -s -e "distinct-values(//node()[attribute::*])" \ | |
| perl -ple 's/\s+$//' \ | |
| cat -s -n | head -100 | |
# attribute names | |
curl -sL "${url}${urlparams}" | xidel -s -e 'distinct-values(//@*)' | |
# element names in a document | |
curl -sL "${url}${urlparams}" | xidel -s -e "distinct-values(//*/name())" | xargs | |
# all Dublic-Core metadata from all *.svg documents in the current directory tree | |
grep -lR metadata * 2>/dev/null \ | |
| xargs -i xidel -s -e '//metadata//dc:*/normalize-space()' {} \ | |
| cat -s | more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment