computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
8 months ago
|
#!/usr/bin/env bash
|
||
|
|
||
8 months ago
|
# Usage: warm-urls.sh <sitemap-url>
|
||
|
# Example: warm-urls.sh https://www.example.com/sitemap.xml
|
||
8 months ago
|
|
||
|
# Check if sitemap url is provided
|
||
|
if [ -z "$1" ]; then
|
||
|
echo "Please provide sitemap URL" >&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Get all URLs from sitemap
|
||
|
urls=$(curl -s "$1" | grep -o "<loc>[^<]*</loc>" | sed 's#<loc>\(.*\)</loc>#\1#')
|
||
|
|
||
|
failed_urls=()
|
||
|
|
||
|
# Warm up URLs
|
||
|
for url in $urls; do
|
||
|
# Fetch the og:image URL from the meta tags
|
||
|
og_image_url=$(curl -s "$url" | grep -o "<meta property=\"og:image\" content=\"[^\"]*\"" | sed 's#<meta property="og:image" content="\([^"]*\)"#\1#')
|
||
|
|
||
8 months ago
|
# warm the URL
|
||
|
echo "Warming up URL: $url"
|
||
|
if ! curl -s -I "$url" > /dev/null; then
|
||
|
failed_urls+=("$url")
|
||
|
fi
|
||
|
|
||
8 months ago
|
# Warm up the og:image URL
|
||
|
if [ -n "$og_image_url" ]; then
|
||
8 months ago
|
echo "Warming up OG: $og_image_url"
|
||
8 months ago
|
if ! curl -s -I "$og_image_url" > /dev/null; then
|
||
|
failed_urls+=("$og_image_url")
|
||
|
fi
|
||
|
else
|
||
|
echo "No og:image found for $url"
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
# Print failed URLs
|
||
|
if [ ${#failed_urls[@]} -gt 0 ]; then
|
||
|
echo "Failed to warm up the following URLs:" >&2
|
||
|
for failed_url in "${failed_urls[@]}"; do
|
||
|
echo "$failed_url" >&2
|
||
|
done
|
||
|
fi
|