Importante: es posible que los enlaces del sitio sean rutas relativa, si es así hay que añadir el nombre del dominio al recorrido del segundo nivel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#Clase Enlace con información sobre el enlace: URL, tamaño y nivel de recorrido class Enlace { $URL $Long $Level Enlace($URL,$Long,$Level) { $this.URL=$URL $this.Long=$Long $this.Level=$Level } } #Iniciar array $myArray = @() #Recorrer el sitio hasta el segundo nivel, almacenando cada información (clase Enlace) en un array $url="http://www.jesusninoc.com" foreach($links in (Invoke-WebRequest $url).Links.href){foreach($links2 in (Invoke-WebRequest $links).Links.href) {$myArray += [Enlace]::new($links2,(Invoke-WebRequest $links2).RawContentLength,2);start-sleep -s 4;$links2}} $myArray |