Sunday, July 5, 2009

VBScript Scrape Links/IMG tags from URL


args = WScript.Arguments.Count

If args <> 1 Then
Wscript.Echo "usage: ScrapeLinks.vbs URL"
Wscript.Quit
End If

URL = WScript.Arguments.Item(0)

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate URL

Do Until ie.ReadyState = 4
Wscript.sleep 10
Loop

Wscript.Echo "DOCUMENT LINKS"
Wscript.Echo

For each link in ie.Document.Links
Wscript.Echo link, link.InnerText
Next

Wscript.Echo
Wscript.Echo "DOCUMENT IMAGE TAGS"
Wscript.Echo

For each pix in ie.Document.Images
Wscript.Echo pix.Src
Next

ie.Quit
Set ie = Nothing

No comments:

Post a Comment