Skip to content

Commit 9d22683

Browse files
committed
SEO bash
1 parent 22bb6e0 commit 9d22683

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

seo_checker.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# Function to check the Title tag of a website
4+
check_title() {
5+
title=$(curl -s "$1" | grep -o '<title>.*</title>' | sed -e 's/<title>//g' -e 's/<\/title>//g')
6+
if [ -z "$title" ]; then
7+
echo "Title: Not found"
8+
else
9+
echo "Title: $title"
10+
fi
11+
}
12+
13+
# Function to check the Meta Description of a website
14+
check_meta_description() {
15+
meta_desc=$(curl -s "$1" | grep -o '<meta name="description" content=".*">' | sed -e 's/<meta name="description" content="//' -e 's/">//')
16+
if [ -z "$meta_desc" ]; then
17+
echo "Meta Description: Not found"
18+
else
19+
echo "Meta Description: $meta_desc"
20+
fi
21+
}
22+
23+
# Function to check WordPress version
24+
check_wordpress_version() {
25+
wp_version=$(curl -s "$1/readme.html" | grep -i '<h1 id="wordpress-version">' | sed -e 's/<[^>]*>//g')
26+
if [ -z "$wp_version" ]; then
27+
echo "WordPress Version: Not found"
28+
else
29+
echo "WordPress Version: $wp_version"
30+
fi
31+
}
32+
33+
# Function to check WordPress post titles
34+
check_wordpress_posts() {
35+
posts=$(curl -s "$1" | grep -Eo '<h[1-6][^>]*><a [^>]*title="[^"]*"' | sed -E 's/<[^>]*>//g')
36+
if [ -z "$posts" ]; then
37+
echo "WordPress Posts Titles: Not found"
38+
else
39+
echo "WordPress Posts Titles:"
40+
echo "$posts"
41+
fi
42+
}
43+
44+
# Function to check Image Alt attributes
45+
check_image_alt() {
46+
image_alt=$(curl -s "$1" | grep -o '<img [^>]*alt="[^"]*"[^>]*>' | sed -e 's/<img [^>]*alt="//' -e 's/"[^>]*>//')
47+
if [ -z "$image_alt" ]; then
48+
echo "Image Alt Attributes: Not found"
49+
else
50+
echo "Image Alt Attributes: $image_alt"
51+
fi
52+
}
53+
54+
# Function to check the HTTP status code of a website
55+
check_http_status() {
56+
http_status=$(curl -s -o /dev/null -w "%{http_code}" "$1")
57+
echo "HTTP Status Code: $http_status"
58+
}
59+
60+
# Main function to run checks
61+
main() {
62+
if [ $# -eq 0 ]; then
63+
read -p "Enter the website URL: " website_url
64+
else
65+
website_url=$1
66+
fi
67+
68+
echo "Checking SEO for: $website_url"
69+
check_title "$website_url"
70+
check_meta_description "$website_url"
71+
check_wordpress_version "$website_url"
72+
check_wordpress_posts "$website_url"
73+
check_image_alt "$website_url"
74+
check_http_status "$website_url"
75+
}
76+
77+
# Call main function
78+
main "$@"

0 commit comments

Comments
 (0)