本帖最后由 terse 于 2019-8-29 22:53 编辑
这样可以吗- @set @i=0 /* & @echo off & >提取结果.txt cscript.exe -NoLogo -E:JScript %0 <单词列表.txt & pause exit */
- var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
- function GetContent(url) {
- xmlhttp.open("GET", url ,false);
- xmlhttp.send();
- return(xmlhttp.responseText);
- };
-
- while (!WSH.StdIn.AtEndOfStream) {
- var str = WSH.StdIn.ReadLine();
- if (str) {
- var url = "http://dict.cn/" + str;
- var html = new ActiveXObject("htmlfile");
- html.write(GetContent(url));
- var t = html.getElementsByTagName("ul")[0];
- if (t) {
- str += "\t" + t.innerText.replace(/[\r\n]/gm,'') + "。\t";
- if (html.getElementById("dict-chart-basic")) {
- var obj = new Function("return" + unescape(html.getElementById("dict-chart-basic").data))();
- for(var key in obj ){ str += obj[key].percent > 5 ? obj[key].sense + ":"+ obj[key].percent + "%, " : ""};
- }
- };
- else { str += "\t" + "错误" };
- WSH.Echo(str);
- };
- };
复制代码
|