jscript issues with downloading a zip from the Web
Posted: 04 Jun 2020 04:41
HI Folks -
I have the following jscript (that you guys helped me with last year) to download a zip file from the Web. The script stopped working recently and I believe it's due to the format of the Webpage.
If you go to the link, I'm trying to download the "Service Pack" int he right most box. What happened what in the past, there used to be a Windows and Linux pack like the box in the middle, but nows its one single box and i'm not sure how to adjust the code to key in that box.
Does anyone have any idea? Thank you!
I have the following jscript (that you guys helped me with last year) to download a zip file from the Web. The script stopped working recently and I believe it's due to the format of the Webpage.
Code: Select all
@if (@a)==(@b) @end /* Batch part:
@ECHO off &SETlocal
::-- Download Link --::
CSCRIPT //nologo //e:jscript "%~fs0" "ME_PS_PATH=C:\ManageEngine\ServiceDesk\Patch_Sets"
pause
JScript Part : */
var objIE = null;
try {
WScript.ECHO('Searching link ...');
objIE = new ActiveXObject('InternetExplorer.Application');
// objIE.Visible = true;
objIE.Navigate('https://www.manageengine.com/products/service-desk/service-packs.html');
while (objIE.Busy) { WScript.Sleep(100); }
var link = objIE.document.getElementsByClassName('box-table mT20')[0].getElementsByTagName('tr')[2].getElementsByTagName('td')[2].getElementsByTagName('a')[0].getAttribute('href');
objIE.Quit();
objIE = null;
WScript.ECHO('Found: ' + link);
WScript.ECHO('Downloading ...');
var objXMLHTTP = new ActiveXObject('MSXML2.ServerXMLHTTP');
objXMLHTTP.open('GET', link, false);
objXMLHTTP.send();
var objADOStream = new ActiveXObject('ADODB.Stream');
objADOStream.Type = 1;
objADOStream.Mode = 3;
objADOStream.Open();
objADOStream.Write(objXMLHTTP.responseBody);
objADOStream.Position = 0;
WScript.ECHO('Saving ...');
var objFSO = new ActiveXObject('Scripting.FileSystemObject');
objADOStream.SaveToFile(objFSO.BuildPath(WScript.Arguments(0), objFSO.GetFileName(link)), 2);
objADOStream.Close();
}
catch(e) {
if (objIE != null) { objIE.Quit(); }
WScript.ECHO('Error!');
}
Does anyone have any idea? Thank you!