saving file with download prompt with vbscript -
I am using VBscript to use IE to open a webpage - login - and some data is a file Saves in
Why Use IE? - I can use VBScript to interact with the webpage - Webpage uses ajax to verify and sign in, so just using MSXML2.XMLHTTP Wont work
After logging into the IE site, I have to direct it to the page I Want to save as a file, problem is returning this page JSON data (filename.json) - so open IE / save / SaveAs is the excitement instead of opening the page, so I can not save the page's data.
The code is below. Any help is greatly appreciated
set IE = WScript.CreateObject ("InternetExplorer.Application", "IE_") IE.Visible = true IE.Navigate "https: // Www.somesite.com "IE" with IE.Documentation .getElementByID "(Username"). Value = "myusername" .getElementByID ("password"). Value = "mysecret" .getElementsByName ("Login") (0). Wait till the end of the end. With 'IE' all OK, logged in and redirected to the members page. IE.Navigate "https://www.somesite.com/api/data" '#This link gives Jason data' # This is where everything stops because I'm getting a download / IE> Edit: OK, I get IE to download the .json file as text files instead of displaying the content files to edit the registry Was able, now the problem page is a json file, not an html file, so i have this normal html Pages like IE.Document.Body.Inner HTML can not get the content given by the phone.
I'll find the contents of the page and specify it in a variable so that I can process it?
Oh, I just put this in my code:
set objShell = CreateObject ("WScript.Shell") objShell.RegWrite "HKEY_CLASSES_ROOT \" This way the file is considered as a text file in IE and it will open only in the page. So I use the normal objIE.Document.Body.InnerText I can use JSON content for that. Then I pass that variable to my function which decodes it all. Hope this helps someone So, as all results from Google'm not helping my only post this because I have this old thread!
Cheers, Ross
Comments
Post a Comment