VBScript to open webpage and save the text contents into a variable

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

saxah999

Thread Starter
Joined
Nov 4, 2011
Messages
5
Hi! I have been dealing with so many limmitations of HTA using VBScript and I badly need rescueing :( I'm creating HTA applications using VBScript and I can't opt to use any other languages or work arround since I don't have time to learn new languages and I'm trying to use these softwares at the office. I cant install any other softwares to use since the IT Department is strict when it comes to installing and downloading non work-related files. Though my softwares are useful, IT dept wont agree with me.

One of the problems I'm having right now is creating a VBScript on HTA that will open an IE browser, get all the text content in it, then save it to a variable. Something like "a = webpage.texts". I have searched google and got frustrated with the work arrounds other forums show. Is there any way to achieve this using just vbscript on HTA and using a non-admin login to a windows7 computer? I was able to use this code but for some reason it only worked for a while, then it stopped working (Showing error). I'm not sure if I may have changed something on the code. Please reply if you have any solutions :(

Function NetSolWhoIs(myDomain, myTimeOut)
Set fukie = CreateObject("InternetExplorer.Application")
fukie.Visible = false
fukie.Navigate2 "https://www.networksolutions.com/whois/registry-data.jsp?domain=" & Trim(myDomain)
WaitLang = window.setInterval("relaylang",3000)
End Function

Function relaylang
msgbox fukie.Document.Body.InnerText '<<<<< THIS SHOWS UNSPECIFIED ERROR (CODE-0)
document.GetElementByID("PingSummary").value = document.GetElementByID("PingSummary").value & vbcrlf & mid(fukie.Document.Body.InnerText,instr(fukie.Document.Body.InnerText,"Domain Name:"),instr(fukie.Document.Body.InnerText,"<<<")-instr(fukie.Document.Body.InnerText,"Domain Name:"))
window.clearInterval(WaitLang)
end Function
 

saxah999

Thread Starter
Joined
Nov 4, 2011
Messages
5
Nobody seem to reply on this website forum. :( I tried something else though. I placed an error handler instead to avoid getting error pop-ups but it may not be a good idea since I'm using on error resume next, which reads next line and ignores error messages (some important linecodes may get bypassed).
 
Joined
Sep 4, 2003
Messages
4,916
Is this true VB script or are you talking about a VBA macro? I tried the code you posted and it works fine for me.

Rollin
 

saxah999

Thread Starter
Joined
Nov 4, 2011
Messages
5
It's VBScript, not the VBA. I'm using HTA(HTML App). Here's what I've noticed, sometimes it works, sometimes it doesn't. I think it fails if the IE page state is not yet ready when it read the line "fukie.Document.Body.InnerText". If that is the case then I may be doomed.0~0 I have no way to counter that since I have no idea how to do sleep or wscript.sleep using VBS on HTA, for some reason, it doesnt know what WSCRIPT is. Probably not installed on my computer. Also I dont have any way to put timer on HTA so it would wait until IE becomes ready to give "fukie.Document.Body.InnerText".
 

saxah999

Thread Starter
Joined
Nov 4, 2011
Messages
5
For wscript? Yes, it pops up "Object Required wscript" when using the code "wscript.sleep". I think I found the solution though. It seems that, depending on your internet connection speed, if the .navigate2 has not fully opened the page, the document.body.innertext code gets an error since it has not captured the texts on the site yet due to the page not beeing fully loaded. I found out about the code to loop until .navigate2 becomes ready and not busy. I do not seem to get the error so far.:)

I'd like to thank you Rollin_Again for helping me out. Is this forum new and active by the way? I did not get much replies so I thought there were no more people in here :p
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top