Submit multiple URLS to gtmetrix using their API
This file contains 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
#!/bin/bash | |
# Config | |
GTMETRIX_API_KEY= | |
SLEEP_TIME=5 | |
# Functions | |
function submit_test { | |
curl -s -u $GTMETRIX_API_KEY: \ | |
-X POST -H Content-Type:application/vnd.api+json \ | |
"https://gtmetrix.com/api/2.0/tests" \ | |
-d '{"data":{"type":"test","attributes":{"url":"'$URL'"}}}' | |
} | |
# Loop through URLs and submit tests | |
for URL in "$@"; do | |
test=`submit_test` | |
while [[ $test == *'status":"429"'* ]]; do | |
sleep $SLEEP_TIME | |
test=`submit_test` | |
done | |
echo "Submitted test for: $URL" | |
done | |
echo "Tests submitted, check results by logging in at https://gtmetrix.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment