Last active
September 5, 2024 09:55
-
-
Save egstar/5522a20d981755e00acf24613c040eff to your computer and use it in GitHub Desktop.
getmeta function
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
######################## | |
# SEO Tracker Function # | |
######################## | |
# Requirements: | |
# OS: any dist | |
# Libraries: [wget, pup, jq] | |
# | |
# Usage: getmeta [URI] | |
# e.g: getmeta example.com | |
# | |
# Returns: | |
# titile, h1 elements and all meta tags | |
# | |
# All credits to Burham Soliman | |
# https://www.burhams.com | |
# https://github.com/egstar | |
##################################; | |
function getmeta { | |
url=$1 | |
if [ -z "$url" ]; then | |
echo "Usage: getmeta <url>" | |
return 1 | |
fi | |
wget -q -O - "$url" | pup 'title, h1, meta json{}' | jq -r '.[] | | |
def colors: | |
{ | |
"black": "\u001b[30m\u001b[47m", | |
"red": "\u001b[31m\u001b[1m", | |
"green": "\u001b[32m", | |
"yellow": "\u001b[33m", | |
"blue": "\u001b[38;5;6m", | |
"magenta": "\u001b[35m", | |
"cyan": "\u001b[36m", | |
"white": "\u001b[37m\u001b[46;1m", | |
"bgfb": "\u001b[42;1m\u001b[30m\u001b[4m", | |
"brfw": "\u001b[41;1m\u001b[37m\u001b[4m", | |
"byfb": "\u001b[43;1m\u001b[30m\u001b[4m", | |
"bbfw": "\u001b[48;5;4m\u001b[37m\u001b[1m", | |
"reset": "\u001b[0m", | |
}; | |
if .charset then colors.brfw+" CHARSET "+colors.reset+" : "+ colors.red+" "+.charset+" "+colors.reset | |
elif .tag=="h1" then colors.bgfb+" "+.tag+" "+colors.reset+" : "+colors.green+" \(.text // .children[].text) "+colors.reset | |
elif .tag=="title" then colors.byfb+.tag+colors.reset+" : " + colors.yellow+" "+.text+" "+colors.reset | |
else colors.bbfw +" \(.name // .property) "+colors.reset+" : "+colors.blue+" "+.content+" "+colors.reset end ' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment