如何从网页获取外部域/来源列表

I'm looking for a way to get all external domains used for a website.

For example: stackoverflow.com

googletagservices.com, google-analytics.com, fbcdn.net, i.stack.imgur.com, cdn.sstatic.net.

Is there a way to get this list of domains in bash or php? My google-fu is failing me.

basically this list:

enter image description here

another example using webpagetest.org

enter image description here