A quick way to get all resource domains which are currently requested by a webpage
1 min readMar 10, 2020
For website optimization, one of the necessary steps is to get all the external resources that our web app is currently requesting. So below is a pretty quick way for getting all external resource domain names in just a blink of an eye.
- Go to a web page from which you want to extract all requested resource domains
- Hit Cmd+Shift+J to open the Chrome developer console, go to Networks tab
- Click the Export icon on the far right of the network tab and save the HAR file
- Create a .sh file to save this script ( to extract unique resource domain):
#list unique resource domainsjq '.log.entries[].request | {method,url}' $1 | jq 'if .method=="GET" then .url else "" end' | grep -Eo "http(s?)://([^/]+)./" | sort | uniq
- Provide the script with executing right:
chmod +x filename.sh
- Execute the script with the previously downloaded har file passed in as an argument:
./filename.sh path/to/har/file
Gist credit: https://gist.github.com/yelkhatib/5403183