Reputation: 11
I am trying to use VBS to gather names of files from a website. I can get the HTML code but I don't know how to extract the name. I haven't yet found anything that can do what I need. I need to extract the name of a file from a table. The HTML around what I need looks like this tsc_details.php?show_id=
NEEDED INFO">
There are many different names formatted this same way and the number of names will vary from time to time.
NOTE: There will be multiple of these at various places in the HTML code.
Here is my code
On Error Resume Next
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "WWW.Webpage.com"
ie.Visible = True
While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
ie.document.getElementById("f_user").Value = "user"
ie.document.getElementById("f_pass").Value = "pass"
ie.document.All.Item("submitb").Click
While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
This is all of the code I have. It works perfectly for logging in to the page I just don't know how to get the Information I need.
Upvotes: 0
Views: 992
Reputation: 11
Figured it out and wanted to share my findings in case it helped someone out.
For Each a In IE.Document.GetElementsByTagName("A")
If InStr(a.GetAttribute("href"),"tsc_details.php?show_id=") > 0 Then
var = a.GetAttribute("href")
var = Replace(var,"tsc_details.php?show_id=","")
exit for
end if
next
Used this code
Upvotes: 0