- //&cls&cscript.exe -nologo -e:jscript "%~f0"&pause&exit/b
-
- var loadText = function (FileIn,Charset){
- var stm = new ActiveXObject('ADODB.Stream');
- stm.Type = 2;
- stm.Mode = 3;
- stm.Charset = Charset;
- stm.Open();
- stm.LoadFromFile(FileIn);
- stm.Position = 0;
- return stm.ReadText;
- }
- var saveText = function (str,FileOut,Charset){
- var stm = new ActiveXObject('ADODB.Stream');
- stm.Type = 2;
- stm.Mode = 3;
- stm.Charset = Charset;
- stm.Open();
- stm.WriteText(str);
- return stm.SaveToFile(FileOut,2);
- }
-
- var f1 ='key.txt',f2 ='host.txt',f3 ='moban.txt';
- var keytxt = loadText(f1,'utf-8').split('\r\n');
- var hosttxt = loadText(f2,'gbk').split('\r\n');
- var mobantxt = loadText(f3,'utf-8');
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- for (var i=0; i<hosttxt.length; i++)
- {
- fso.CreateFolder('.\\'+hosttxt[i]);
- var folder = '.\\'+hosttxt[i]+'\\www.'+hosttxt[i]+'\\';
- fso.CreateFolder(folder);
- var htmtxt = mobantxt;
- for (var j=1; j<5; j++)
- {
- var n = Math.floor(Math.random()*keytxt.length);
- var re =new RegExp('关键词'+j,'g')
- var tmptxt = htmtxt.replace(re,keytxt[n]);
- htmtxt = tmptxt;
- }
- saveText(htmtxt,folder+'index.htm','utf-8');
- }
复制代码
|