本帖最后由 pcl_test 于 2016-8-21 16:20 编辑
- //&cls&cscript -nologo -e:jscript "%~f0"&pause&exit
-
- //编码转换
- function BintoStr(strBin,strCharset){
- try{
- var stream = new ActiveXObject('ADODB.Stream')
- stream.Type = 1
- stream.Mode = 3
- stream.Open()
- stream.Write(strBin)
- stream.Position = 0
- stream.Type = 2
- stream.Charset = strCharset
- return stream.ReadText
- }
- catch(e){}
- }
-
- //获取网页内容
- function getHtmlTxt(url, strCharset){
- try{
- var http = new ActiveXObject('MSXML2.XMLHTTP')
- }
- catch(e){
- var http = new ActiveXObject('WinHttp.WinHttpRequest.5.1')
- }
- http.open('GET', url, false)
- http.send()
- return BintoStr(http.ResponseBody, strCharset);
- }
-
- //纯实现,可直接下载http://www.yqhhy.cc/modules/article/packdown12.php?id=54335&type=txt
- //章节
- var chapter=[2868608,2868609,2868610,2868611,2868612,2868613,2868614,2868615,2868616,2868617,2868618,2868619,2868620,2868621,2868622,2868623,2868624,2868625,2868626,2868627,2868628,2868629,2868630,2868631,2868632,2868633,2868634,2868635,2868636,2868637,2868638,2868639,2868640,2868641,2868642,2868643,2868644,2868645,2868646,2868647,2868648,2868649,2868650,2868651,2868652,2868653,2868654,2868655,2868656,2868657,2868658,2868659,2868660,2868661,2868662,2868663,2869257,2870837,2872851,2872852,2875074,2875340,2879312,2881646,2881647,2884297,2886886,2888072,2888073,2888797,2894304,2894305,2896700,2896701,2898723,2910028];
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- for(var i=0;i<chapter.length;i++){
- var text = getHtmlTxt('http://www.yqhhy.cc/54/54335/'+chapter[i]+'.html', 'gbk').replace(/ /g,' ').replace(/<br \/>|<br\/>|<br>/g,'\r\n');
- var m = text.match(/<h1\s?[^<]*?>[\s\S]+?<\/h1>|<div id=\"content\">[\s\S]+?<\/div>/ig);
- if(m){
- var title = m[0].replace(/<[^<]+>/g,'').replace(/^\s*|\s*$/g,'');
- var content = m[1].replace(/<[^<]+>/g,'').replace(/.*言情后花园(.*www.yqhhy.cc)?.*/ig,'').replace(/(\r?\n)+/g,'\r\n');
- }
- var f=fso.OpenTextFile('结果.txt', 8, true)
- f.Write(title+'\r\n'+content+'\r\n');
- f.Close();
- WSH.echo((i+1)+'、'+title);
- }
复制代码
|