, . , , , - ( , , , ).
querySelector , , "fileList". href .
@if (@CodeSection == @Batch) @then
@echo off & setlocal
set "html=test.html"
for /f "delims=" %%I in ('cscript /nologo /e:JScript "%~f0" "%html%"') do set "%%I"
echo %build%
goto :EOF
@end // end batch / begin JScript hybrid code
var htmlfile = WSH.CreateObject('htmlfile'),
fso = WSH.CreateObject('Scripting.FileSystemObject'),
file = fso.OpenTextFile(WSH.Arguments(0), 1),
html = file.ReadAll();
file.Close();
htmlfile.write('<meta http-equiv="x-ua-compatible" content="IE=9" />' + html);
var anchors = htmlfile.querySelectorAll('table.fileList a');
for (var i = 0; i < anchors.length; i++) {
if (/webservice-((\d+\.)*\d.+)\.var$/i.test(anchors[i].href)) {
WSH.Echo('build=' + RegExp.$1);
WSH.Quit(0);
}
}
, HTML , , -, Microsoft.XMLHTTP HTML- wget curl . .
@if (@CodeSection == @Batch) @then
@echo off & setlocal
set "URL=http://www.domain.com/file.html"
for /f "delims=" %%I in ('cscript /nologo /e:JScript "%~f0" "%URL%"') do set "%%I"
echo %build%
goto :EOF
@end // end batch / begin JScript hybrid code
var xhr = WSH.CreateObject('Microsoft.XMLHTTP'),
htmlfile = WSH.CreateObject('htmlfile');
xhr.open('GET', WSH.Arguments(0), true);
xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
xhr.send('');
while (xhr.readyState != 4) WSH.Sleep(50);
htmlfile.write('<meta http-equiv="x-ua-compatible" content="IE=9" />' + xhr.responseText);
var anchors = htmlfile.querySelectorAll('table.fileList a');
for (var i = 0; i < anchors.length; i++) {
if (/webservice-((\d+\.)*\d.+)\.var$/i.test(anchors[i].href)) {
WSH.Echo('build=' + RegExp.$1);
WSH.Quit(0);
}
}