本帖最后由 happy886rr 于 2017-9-3 09:15 编辑
回复 3# hlzj88 - 1>1/* :
- @echo off
- REM 开启变量延迟
- setlocal enabledelayedexpansion
-
- REM 设置头条网址
- set "URL=http://www.toutiao.com/"
-
- REM 遍历文件源,提取每个头条ID
- for /f "tokens=1,2 delims=|" %%i in (4.txt) do (
- set/a "i+=1"
- set "LIST[!i!]=%%i#%%j.html"
- )
-
- REM 获取列表长度
- set "LIST_SIZE=!i!"
-
- REM 已下载计数
- set "ALREADY_GET=0"
-
- REM 主体循环
- :LOOP
- REM 遍历列表数组
- for /l %%N in (1,1,!LIST_SIZE!) do (
- if not "!LIST[%%N]!"=="" (
- for /f "tokens=1,2 delims=#" %%i in ("!LIST[%%N]!") do (
- echo GET[!ALREADY_GET!/!LIST_SIZE!]: "%%j"
- if not exist ".\%%j" (
- cscript -nologo -e:jscript "%~f0" "%URL%" "%%i" "%%j"
- )
- if exist ".\%%j" (
- set/a "ALREADY_GET+=1"
- set "LIST[%%N]="
- echo OK.
- )
- )
- )
- )
- REM 执行完毕
- if !ALREADY_GET! equ !LIST_SIZE! (
- set/p =END.
- exit/b
- )
- goto :LOOP
- */
- //////////////////////////////////////////////////////////////
- function GetTTList(hostURL)
- {
- var xmlHTTP = new ActiveXObject('Msxml2.XMLHTTP');
- xmlHTTP.open('GET', hostURL, false);
- xmlHTTP.send();
- respJson=xmlHTTP.responseText;
- if(respJson)
- {
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var f = fso.openTextFile(WScript.arguments(2), 2, true);
- var parseData = (eval('('+respJson+')'))['data'];
- if(parseData.length > 0)
- {
- for(var i=0; i<parseData.length; i++)
- {
- f.writeLine('<a href="' + WScript.arguments(0) + parseData[i]['source_url'] + '" target="_blank">' + '[' + eval('i+1') + '].' + parseData[i]['title'] + '</a>' + '<br>');
- }
- }else{
- f.writeLine('<b>Not found any articles!</b>');
- }
- f.close();
- }
- }
- var hostURL = WScript.arguments(0) + '/c/user/article/?page_type=1&user_id=' + WScript.arguments(1) + '&max_behot_time=0&count=256';
- GetTTList(hostURL);
- //////////////////////////////////////////////////////////////
复制代码
|