本帖最后由 terse 于 2014-11-6 12:28 编辑
最后结果正确不
我这里测 是可行的 (XP 和 WIN7)- @if(0)==(0) echo off
- for %%a in (*.htm) do CScript.exe //NoLogo //E:JScript "%~f0" "%%a">%%~na.txt
- pause & exit
- @end
- function WriteCenterLogs(a,b,c,d,e,f,g,h,i) {WScript.Echo(a + '\t' + b + '\t' + c + '\t' + d + '\t' + e+ '\t' + g)}
-
- function adoLoadText(filename, charset) {
- var stream, text;
- stream = new ActiveXObject("ADODB.Stream");
- stream.type = 2;
- stream.charset = charset;
- stream.open();
- stream.loadFromFile(filename);
- text = stream.readText(-1);
- stream.close();
- return text;
- }
-
- var file = WScript.Arguments.Item(0);
- var next = adoLoadText(file ,'UTF-8');
- var html = new ActiveXObject("htmlfile");
- html.write(next);
- var d = html.getElementsByTagName("dd");
- var len = d.length;
- for (var i = 0; i < len; i++) {
- var s = d[i].getElementsByTagName("div");
- s = s[0].getElementsByTagName('a')[0].onclick;
- s();
- }
复制代码 废了对象 还是直接正则获取 这样试下
发现正则有点问题- @if(0)==(0) echo off
- dir /b *.htm | CScript.exe //NoLogo //E:JScript "%~f0"
- pause & exit
- @end
-
- function adoLoadText(filename, charset) {
- var stream, text;
- stream = new ActiveXObject("ADODB.Stream");
- stream.type = 2;
- stream.charset = charset;
- stream.open();
- stream.loadFromFile(filename);
- text = stream.readText();
- stream.close();
- return text;
- }
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var re = new RegExp('<dd>[^(]+\\((.+)\\);\" target=','img')
- while (!WScript.StdIn.AtEndOfStream){
- var file = WScript.StdIn.Readline();
- var name = file.replace(/(.+?)(\.[^\.]*?)$/gi,'$1.txt');
- var next = adoLoadText(file ,'UTF-8');
- var arr = getarr(next);
- fso.CreateTextFile(name, true).Write(arr.join('\r\n'))
- }
-
- function getarr(next) {
- var f = next.match(re),arr = [];
- if (f){
- var len = f.length;
- for (var i = 0; i < len; i++){
- var str = f[i];
- str = str.replace(re,'$1');
- var tar = str.replace(/^'|'$/g,'').replace(/\t/g,' ').split(/','/);
- tar.splice(5, 1)
- arr[i] = tar.join('\t')
- }
- return arr;
- }
- }
复制代码
|