I believe this will do what you want, though I suspect there is a more direct way that does not require opening the page ...
sURL1 = "https://www.google.com/accounts/ServiceLogin?service=finance" sURL2 = "http://www.google.com/finance/portfolio?action=view&pid=4" sFilename = "D:\Someplace\somename.html" with CreateObject("InternetExplorer.Application") .Navigate sURL1 Do until .ReadyState = 4 : WScript.Sleep 100 : Loop .visible = true With .document.all .email.value = "you...@yourdomain.com" .passwd.value= "yourpassword" ' or Inputbox to ask the password .signin.click End With ' document .Navigate sURL2 Do until .ReadyState = 4 : WScript.Sleep 100 : Loop sText = .document.body.outerHTML with createobject("scripting.filesystemobject") .OpenTextFile(sFilename, 2, true, true).write sText end with ' FSO .quit ' optional End With ' IE _____________________ Tom Lavedas
> I believe this will do what you want, though I suspect there is a more > direct way that does not require opening the page ...
{code snipped}
I knew there was a more direct method ...
sURL2 = "http://www.google.com/finance/portfolio?action=view&pid=4" sFilename = "D:\Someplace\somename.html" ' Get page sUID = "you...@yourdomain.com" sPW = "password" sData = GetXml(sPage, sUID, sPW) 'now save the page to a file. CreateObject("Scripting.FileSystemObject")._ OpenTextFile(FilePath, 2, True, true).Write sData
Wscript.Echo "Done"
Function GetXml(sURL, userID, Password) ' Create an xmlhttp object: With CreateObject("Microsoft.XMLHTTP") .open "GET", sURL, false, userID, password .send GetXml = .responseText End With End Function
With later versions of IE (7+) loaded, I believe the "Microsoft.XMLHTTP" is replaced with the "XMLHttpRequest" object instead. _____________________ Tom Lavedas
> > I believe this will do what you want, though I suspect there is a more > > direct way that does not require opening the page ...
> {code snipped}
> I knew there was a more direct method ...
> sURL2 = "http://www.google.com/finance/portfolio?action=view&pid=4" > sFilename = "D:\Someplace\somename.html" > ' Get page > sUID = "you...@yourdomain.com" > sPW = "password" > sData = GetXml(sPage, sUID, sPW) > 'now save the page to a file. > CreateObject("Scripting.FileSystemObject")._ > OpenTextFile(FilePath, 2, True, true).Write sData
> Wscript.Echo "Done"
> Function GetXml(sURL, userID, Password) > ' Create an xmlhttp object: > With CreateObject("Microsoft.XMLHTTP") > .open "GET", sURL, false, userID, password > .send > GetXml = .responseText > End With > End Function
> With later versions of IE (7+) loaded, I believe the > "Microsoft.XMLHTTP" is replaced with the "XMLHttpRequest" object > instead. > _____________________ > Tom Lavedas
Hi Tom Thank. it works on First VBS. Due to I does not have IE(7+). I can not test on second vbs.
>> I believe this will do what you want, though I suspect there is a more >> direct way that does not require opening the page ... > {code snipped}
> I knew there was a more direct method ...
> sURL2 = "http://www.google.com/finance/portfolio?action=view&pid=4" > sFilename = "D:\Someplace\somename.html" > ' Get page > sUID = "you...@yourdomain.com" > sPW = "password" > sData = GetXml(sPage, sUID, sPW) > 'now save the page to a file. > CreateObject("Scripting.FileSystemObject")._ > OpenTextFile(FilePath, 2, True, true).Write sData
> Wscript.Echo "Done"
> Function GetXml(sURL, userID, Password) > ' Create an xmlhttp object: > With CreateObject("Microsoft.XMLHTTP") > .open "GET", sURL, false, userID, password > .send > GetXml = .responseText > End With > End Function
> With later versions of IE (7+) loaded, I believe the > "Microsoft.XMLHTTP" is replaced with the "XMLHttpRequest" object > instead. > _____________________ > Tom Lavedas
IE7+ have both versions so you can use either. Personally I would use msxml2.Xml.3.0 which is "all" machines and is usually better than the original microsoft.xmlhttp. If you're running on a specific machine that you know has the latest update then use msxml2.XmlHttp.6.0.