Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get links using document.getelementsbyTag('a")

Status
Not open for further replies.

tommytx

Programmer
Nov 27, 2002
28
US
Here is what I am trying:

Set WshShell = WScript.CreateObject("WScript.Shell")
Dim ie
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = TRUE
ie.Navigate(" Do until ie.ReadyState = 4
WScript.Sleep 50
Loop
WshShell.AppActivate "My Test Form"
set urls = ie.document.all.tags("a")

' wsh.echo urls[0].innerHTML
' wsh.echo ie.document.all.tags("a")[0].innerHTML

toturls = urls.length

wsh.echo "Number of URLs:", toturls, vbNewline

All of it works, except the two that have been remarked out as they fail.. what I want to be able to do is extract the actual url from the array in urls.

Any help would be appreciated.... it seems to work with javascript, but I need it to work with vbscript.
 
>' wsh.echo urls[0].innerHTML
[tt]wsh.echo urls(0).innerHTML
'or
wsh.echo urls.item(0).innerHTML[/tt]

>' wsh.echo ie.document.all.tags("a")[0].innerHTML
The same.
[tt]wsh.echo ie.document.all.tags("a")(0).innerHTML[/tt]
 
here you go, this will give you the url as well:


Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = TRUE
ie.Navigate(" Do until ie.ReadyState = 4
WScript.Sleep 50
Loop

set urls = ie.document.all.tags("a")
For x = 0 to (urls.length)-1
wscript.echo urls(x).innerHTML & " : " & urls(x).href
Next
wscript.echo "Number of URLs:", urls.length, vbNewline




regards,

Marty,
Editor:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top