The VBScript Network and Systems Administrator's Cafe

Oct 31 2008   6:17AM GMT

Using Internet Explorer objects to scrape links from web pages.

Jerry Lees Jerry Lees Profile: Jerry Lees

 Recently, I needed to write a tool that would scrape the links from a page. To accomplish this I used the Internet Explorer object “InternetExplorer.Application“.  We’ll explain it a bit more in a later entry but for now, take a look at the code below:

URL = “http://itknowledgeexchange.techtarget.com/itblogs/

With CreateObject(“InternetExplorer.Application”)
  .Navigate URL
  Do Until .ReadyState = 4
    Wscript.sleep 10
  Loop
  for each link in .document.links
    Wscript.echo link, link.InnerText
  next

‘ Uncomment the three lines below to scrape references to images
‘  for each pix in .document.images
‘  Wscript.echo pix.src
‘  Next
 
  .Quit
End With

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: