Tracking third party URLs (In Javascripts)

Hi

I want to know how can we get the list of URLs/IPs the website is getting connected, i have made following small script but it is not able to collect all the links which are mentioned in the javascripts etc

 

$path = Get-Content -Path ‘C:\URL Internal Links Scanner\URLlist.txt’
$path2 = “C:\URL Internal Links Scanner\output.csv”

[int]$i = 0
Foreach ($URL in $path)
{
$a = Invoke-WebRequest -Uri $URL
$links=$a.Links | Where-Object {$_.href -notlike “$url”} |select href
$csp=$a.Headers.‘Content-Security-Policy’
write-host “`n”
$output = $URL +“`t”+ $links.href +“`t”+ $csp
$output | Out-File $path2 -Append

}

 

Basic expectations is

  1. Example URL - www.ndtv.com
  2. When opened - it connects to various third party tracker URLs - example Google Analytics, Google Fonts etc
  3. With above script i am not able to catch such URLs

The links collection in the object returned by Invoke-WebRequest is just a list of clickable links. This does not include all of the various ways a page can cause that browser to access a remote URL. You need a network monitoring tool to see what is actually happening. The easiest tool that you probably already have is the Developer Tools in Chrome. There is a network view in the tool that shows you all the URLs access when a page is loaded.