标题: [文本处理] [已解决]批处理如何将指定文本里的内容按顺序替换掉html文件的特定标签内的内容 [打印本页]
作者: 我来了 时间: 2015-5-20 12:20 标题: [已解决]批处理如何将指定文本里的内容按顺序替换掉html文件的特定标签内的内容
<!-- :
@echo off
mshta "%~f0"
pause & exit /b
-->
<script src=http://www.bathome.net/lib/diy/hide.js></script>
<script src=http://www.bathome.net/lib/diy/iconv.js></script>
<script>
var HtmlText = iconv.loadText('index27.html','utf-8')
var FileNameList = iconv.loadText('要读取的中文名序列.txt','gb2312').match(/[^\s]+/mg)
var newHtmlText = HtmlText.replace(
/("thumbnailtitle"\>).+?(?=\<\/a)/g,
function($0,$1){return $1+FileNameList.shift()}
)
iconv.saveText(newHtmlText,'new.html','utf-8')
</script>
测试文件 就是这个http://pan.baidu.com/s/1gdD2Lxx
,版主哥的一次只能修改一个.html文件,我还得来回修改源代码,这样速度就拖慢了,还请大师再给修改下,弄个进级版的,唉……真是笨死了。
作者: pcl_test 时间: 2015-5-20 15:24
本帖最后由 pcl_test 于 2015-5-20 15:26 编辑
借CrLf大的js库代码弄了这个离线版- @set @n=0; /* & echo off
- md "处理结果\" 2>nul
- dir /b *.html|cscript -nologo -e:jscript "%~0"
- pause & exit/b & rem */
-
- var loadText = function (strFileIn,strCharset){
- try{
- var stream = new ActiveXObject('ADODB.Stream');
- stream.Type = 2;
- stream.Mode = 3;
- stream.Charset = strCharset;
- stream.Open();
- stream.LoadFromFile(strFileIn);
- stream.Position = 0;
- return stream.ReadText;
- }
- catch(Err){}
- }
-
- var saveText = function (strArg,strFileOut,strCharset){
- try{
- var stream = new ActiveXObject('ADODB.Stream');
- stream.Mode = 3;
- stream.Type = 2;
- stream.Charset = strCharset;
- stream.Open();
- stream.WriteText(strArg);
- return stream.SaveToFile(strFileOut,2);
- }
- catch(Err){}
- }
-
- while(!WScript.StdIn.AtEndOfStream){
- var file = WScript.StdIn.ReadLine();
- var HtmlText =loadText(file,'utf-8');
- var FileNameList = loadText('中文名.txt','gb2312').match(/[^\s]+/mg);
- var newHtmlText = HtmlText.replace(/("thumbnailtitle"\>).+?(?=\<\/a)/g,function($0,$1){return $1+FileNameList.shift();});
- saveText(newHtmlText,'./处理结果/new_'+file,'utf-8');
- }
复制代码
作者: 我来了 时间: 2015-5-20 16:25
这次太给力啦,直接一击必杀啊!为什么只能给1技术分太少了。
作者: CrLf 时间: 2015-5-20 16:43
来个纯 hta 的在线版:- <script src=http://www.bathome.net/lib/diy/hide.js></script>
- <script src=http://www.bathome.net/lib/diy/iconv.js></script>
- <script src=http://www.bathome.net/lib/Prototype.js></script>
- <script src=http://www.bathome.net/lib/diy/WSH.js></script>
- <script src=http://www.bathome.net/lib/diy/Function.js></script>
- <script src=http://www.bathome.net/lib/diy/DIYprototype.js></script>
-
- <script>
- dir().grep(/index\d+\.html/)._each(replacehtml)
-
- function replacehtml(HtmlPath,FileNameList){
- var FileNameList = iconv.loadText('中文名.txt','gb2312').match(/[^\s]+/mg)
-
- var HtmlText = iconv.loadText(HtmlPath,'utf-8')
- var newHtmlText = HtmlText.replace(
- /("thumbnailtitle"\>).+?(?=\<\/a)/g,
- function($0,$1){return $1+FileNameList.shift()}
- )
-
- iconv.saveText(newHtmlText,HtmlPath,'utf-8')
- }
- </script>
复制代码
作者: 我来了 时间: 2015-5-20 17:02
感谢老师们支持,要有啥破解软件的差事,小的可以一试。
作者: CrLf 时间: 2015-5-20 19:17
回复 5# 我来了
搜噶,以后有什么破解方面的问题就要请教楼主了
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |