本帖最后由 flashercs 于 2018-9-24 01:37 编辑
- (function(e,t){function i(e,t,i,r,n){this.level=e,this.reChild=t,this.a2=r,this.next=n,this.tableText="",this.tableID=i}function r(e,t,i){var n,a,h,u=s(e);if(null===t.next)return n=t.getContent(u),void o.WriteLine([n[0],i[2],i[1],n[1]].join(f));for("author"===t.level&&(d[i[0]]&&(n=RegExp("<a[^>]+href=[\"']([^\"']+)[\"'][^>]*>\\s*"+l(d[i[0]])+"\\s*</a>","i").exec(u))&&(u=s(x+n[1])),a=T[i[0]]);;){for(;n=t.getChildren(u,a);){if(i.push("author"===t.level?"作者:"+n[1]:n[1]),"title"===t.level){h=n[1]+".txt";try{o=p.OpenTextFile(h,2,!0)}catch(e){c(e,"Opening file "+h);continue}}r(x+n[0],t.next,i),i.pop(),"title"===t.level&&o.Close()}if(!(n=b.exec(u)))break;u=s(x+n[1])}}function n(e){var t,i,n,l,a=["TangShiAllIndex2.html","TangShiAllIndex1.html","TangShiAllIndex.html"],h=/<a[^>]+href=(['"])(.+?)\1[^>]*>\s*第\d+卷\s*<\/a>/gi,u=/<li[^>]+class="LiTitle"[^>]*>\s*<a[^>]+href=["']([^"']+)["'][^>]+?class="Green"[^>]*>\s*(.+?)\s*<\/a>[\S\s]+?<\/li>/gi,g={};try{o=p.OpenTextFile(e,2,!0)}catch(t){return c(t,"Writing to "+e),!1}for(l=a.length-1;l>=0;l--)for(t=s(x+a[l]);n=h.exec(t);)for(i=s(x+n[2]);;){for(;n=u.exec(i);)g[n[1]]||(r(x+n[1],oArc.next.next,["全唐诗","作者:"+n[2]]),g[n[1]]=!0);if(!(n=b.exec(i)))break;i=s(x+n[1])}o.Close()}function l(e){return e.replace(/[()]/g,"\\$&")}function a(e){return e.replace(/^\s+|\s+$|/g,"")}function s(e){return u.open("GET",e,!1),u.send(),200===u.status?u.responseText:(c('fetch URI "'+e+'" failed.\nstatus: '+u.status),"")}function c(e,t){WScript.Echo("[object Error]"===Object.prototype.toString.call(e)?[e.name,"source: "+(void 0===t?"":t),"number: "+(e.number>>>0).toString(16),"equipment: "+(e.number>>16&8191),"code: "+(65535&e.number),"Information: "+e.message].join("\n"):e)}var o,h,u=function(){for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],t=0;t<e.length;t++)try{return new ActiveXObject(e[t])}catch(e){}c("Can't build XMLHTTP automation object."),WScript.Quit(1)}(),p=new ActiveXObject("Scripting.FileSystemObject"),g=new ActiveXObject("WScript.Shell"),x="http://www.chinapoesy.com/",b=/<a[^>]+href="\/([^"]+)"[^>]*>\s*<img\s+src="\/Images\/Pager\/nextn.gif"\s+border="0"[^>]*>\s*<\/a>/i,f="\t",d={"近现代诗":"近现代诗人全集","唐诗":"更多唐诗诗人","宋词":"更多宋词词人","元曲":"更多元曲名家","外国诗歌":"更多外国诗人"},T={"宋词":'id="DDlSongCi"',"元曲":'id="DDlSongCi"',"唐诗":'id="DDlTang"'};i.prototype.getChildren=function(e){var t;return""===this.tableText&&(this.tableText=RegExp("<table[^>]+"+l(this.tableID)+"[^>]*>[\\S\\s]+?</table>","i").exec(e)),(t=this.reChild.exec(this.tableText))?[t[this.a2[0]],t[this.a2[1]]]:(this.tableText="",null)},oArc=new i("content",null,"",null,null),oArc.getContent=function(e,t,i){var r;r=e.split(/<script\s+type="text\/javascript"[^>]*>\s*\$\("#loading"\)\.css\("display","none"\);\s*<\/script>|<(\w+)[^>]+id="Author\d*"[^>]*>[\S\s]*?<\/\1>|<script\s+type="text\/javascript">\s*<!--\s*google_ad_client[^<>]+?google_ad_slot[^<>]+?-->\s*<\/script>/gi);try{return[a(r[1].replace(/(?:<[^<>]*>| )+/g,"")).replace(/[\r\n]/g," "),r[2].replace(/(?:<[^<>]*>| )+/g,function(e){return/(?:<br\s*\/?>|<\/br>)+/i.test(e)?"<br />":""}).replace(/(?:<br \/>|\s)+/gi,"<br />")]}catch(e){return[]}},oArc=new i("article",/<a[^>]+href=["']([^"']+)["'][^>]*>([^<>]+)<\/a>/gi,'id="DLFeelingChina"',[1,2],oArc),oArc.getChildren=function(e,t){var i;return""===this.tableText&&(this.tableText=RegExp("<table[^>]+"+l(t||this.tableID)+"[^>]*>[\\S\\s]+?</table>","i").exec(e)),(i=this.reChild.exec(this.tableText))?[i[this.a2[0]],/\((\d+)\)/.exec(i[this.a2[1]])[1]]:(this.tableText="",null)},oArc=new i("author",/<a[^>]+href=["']([^"']+)["'][^>]*>([^<>]+)<\/a>/gi,'id="DLAtuhor"',[1,2],oArc),oArc.getChildren=function(e,t){var i;return""===this.tableText&&(this.tableText=RegExp("<table[^>]+"+l(t||this.tableID)+"[^>]*>[\\S\\s]+?</table>","i").exec(e)),(i=this.reChild.exec(this.tableText))?[i[this.a2[0]],i[this.a2[1]].replace(/\s+|\(\d*\)/g,"")]:(this.tableText="",null)},oArc=new i("title",RegExp("<a[^>]+href=[\"']/([^\"']+)[\"'][^>]*>("+t.join("|")+")</a>","gi"),'class="top"',[1,2],oArc),h=new Date,g.CurrentDirectory=p.GetParentFolderName(WScript.ScriptFullName),e&&n("全唐诗.txt"),r(x,oArc,[]),WScript.Echo("Mission complete.\nTime elapsed: "+(new Date-h)/1e3+"s"),WScript.Quit()})(!0,["唐诗","宋词","全宋词","元曲","诗经","楚辞","乐府诗集","近现代诗","外国诗歌"]);
- //第一个参数是否下载全唐诗,1=是,0=否;
- //第二个参数是除全唐诗以外的其他栏目列表。
复制代码
|