este es el código que me encontré
var nodos = document.getElementsByTagName("a"); var links = ""; for(i=0;i<nodos.length;i++) {links += nodos[i].href + "<br>"}; document.getElementsByTagName("body")[0].innerHTML = links;
y por acá les dejo el código que diseñe yo
option explicit
dim l,ie,x,web,fso,f
redim imagen(0),urls(0)
set ie = createObject("InternetExplorer.Application")
web = inputbox("ingrese la direccion web")
ie.visible=true
navegar(web)
x=0
do
l = urls(x)
if instr(l,web)<>0 then
navegar(l)
end if
x=x+1
loop while x<=ubound(urls)
set fso = createObject("Scripting.FileSystemObject")
set f = fso.CreateTextFile("enlaces.html")
f.WriteLine("<center><h1>Los links de esta pagina son</h1>")
for x=0 to ubound(urls)
f.WriteLine("<a href='" + urls(x) + "'>" + urls(x) + "</a><br>")
next
f.WriteLine("<h1>Las imagenes de esta pagina son</h1>")
for x=0 to ubound(imagen)
f.WriteLine("<a href='" + imagen(x) + "'>" + imagen(x) + "</a><br>")
next
f.Close
ie.quit
msgbox "Todos Los Link's Han Sido Extraidos Con Exito",,"Terminamos"
''========================================================================================
function buscar(l,op)
dim x
if op = 1 then
for x = 0 to ubound(urls)
if l = urls(x) or l = (urls(x) & "#") then
buscar = false
exit function
end if
next
end if
if op = 2 then
for x = 0 to ubound(imagen)
if l = imagen(x) then
buscar = false
exit function
end if
next
end if
buscar = true
end function
''============================================================================================
function navegar(url)
on error resume next
dim objlink,i,l,img
ie.Navigate(url)
while ie.busy
wend
set objlink = ie.document.getElementsByTagName("a")
for i = 0 to objlink.length
l = objlink(i)
if buscar(l,1) and l <> "" then
redim Preserve urls(ubound(urls)+1)
urls(ubound(urls)) = l
end if
next
set img = ie.document.getElementsByTagName("img")
for i = 0 to img.length
if img(i) <> "" then
l = img(i).src
if buscar(l,2) then
redim Preserve imagen(ubound(imagen)+1)
imagen(ubound(imagen))=l
end if
end if
next
end function
.....:::::ACTUALIZADO:::::.....
En este nuevo código no es necesario el internet explorer
option explicit
dim web,html,url,shell,fso,op
set shell = createobject("wscript.shell")
set html = createobject("htmlfile")
Set web = CreateObject("MSXML2.ServerXMLHTTP")
set fso = createobject("scripting.filesystemobject")
url = inputbox("Ingrese Una Direccion Web","Url Valida")
op = inputbox("1- Presione 1 Para Extraer Solo Link's" & vbCrlf & vbCrlf & "2- Presione 2 Para Extraer Solo Imagenes")
web.open"GET",url,False
web.send
html.write web.responsetext
if op = 1 then
enlaces
elseif op = 2 then
imagenes
else
msgbox "Solo Presione 1 o 2",48,"Opcion no Definida"
end if
'================================================================================================='
function enlaces
on error resume next
dim objlink,i,log,l,f,p,u
set objlink = html.getElementsByTagName("a")
wscript.sleep 2000
if objlink.length=0 then
msgbox "Cero Enlaces Encontrados Ya Que La Pagina No Tiene o Esta Protegida",,"Aviso"
else
for i = 0 to objlink.length
l = objlink(i)
if instr(log,l) = 0 then
log = log & l & vbcrlf
end if
next
p = instrrev(url,"/")
if p = len(url) then
p = p - 1
p = instrrev(url,"/",p)
end if
u = mid(url,1,p)
log = replace(log,"about:",u)
set f=fso.createtextfile("index.txt")
f.write(log)
f.close
shell.run "index.txt"
end if
end function
'================================================================================================='
function imagenes
on error resume next
dim img,i,log,l,f,p,u
set img = html.getElementsByTagName("img")
wscript.sleep 2000
if img.length=0 then
msgbox "Cero Imagenes Encontradas Ya Que La Pagina No Tiene o Esta Protegida",,"Aviso"
else
for i = 0 to img.length
l = img(i).src
if instr(log,l) = 0 then
log = log & l & vbcrlf
end if
next
p = instrrev(url,"/")
if p = len(url) then
p = p - 1
p = instrrev(url,"/",p)
end if
u = mid(url,1,p)
log = replace(log,"about:",u)
set f=fso.createtextfile("index.txt")
f.write(log)
f.close
shell.run "index.txt"
end if
end function
Bueno saludos Flamer y a ver a quien le sirve de algo
No hay comentarios.:
Publicar un comentario