I'm using VBscript to use IE to open a webpage - login - and save some data to a file.
Why use IE? - I can use VBScript to interact with the webpage - The webpage uses ajax to do verification and signing in, so simply using MSXML2.XMLHTTP wont work.
After IE log into the site, I direct it to the page I want to save as a file, the problem is this page is returning JSON data (filename.json) - so IE is prompting to open/save/saveas rather than just opening the page, so I cant save the data of the page.
The code is below. Any help is much appreciated.
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "https://www.somesite.com"
Wait IE
With IE.Document
.getElementByID("username").value = "myusername"
.getElementByID("password").value = "mysecret"
.getElementsByName("Login")(0).Click
End With
Wait IE
'# all fine here, logged in and redirected to members page
IE.Navigate "https://www.somesite.com/api/data"
' # this link returns json data
'# this is where everything stops because Im getting a download/save as prompt in IE
EDIT: ok, I was able to get IE to display the content rather than downloading it by editing the registry to treat .json file as text files,Now the problem is the page is a json file, not a HTML file, so I cant get it's content by calling IE.Document.Body.InnerHTML like normal HTML pages.
How would I get the content of the page and assign it to a variable so I can process it?