Option Explicit Const CSS_PATH = "../style.css" ' Recordsetのフィールド定数 Const adVarChar = 200 Const adInteger = 3 Const adDBTimeStamp = 135 Dim g_sScriptDir: g_sScriptDir = Replace(WScript.ScriptFullName, WScript.ScriptName,"") Dim g_oWshShell: Set g_oWshShell = CreateObject("Wscript.Shell") Dim g_oFso: Set g_oFso = CreateObject("Scripting.FileSystemObject") Dim oRst: Set oRst = CreateObject("ADODB.Recordset") oRst.Fields.Append "no", adVarChar,255 oRst.Fields.Append "path", adVarChar,255 oRst.Fields.Append "datetime", adVarChar,255 oRst.Fields.Append "title", adVarChar,255 oRst.Fields.Append "url", adVarChar,255 oRst.Open ' ファイル内から文字列を取得 Dim oFolder: Set oFolder = g_oFso.GetFolder(g_sScriptDir) Dim oItem For Each oItem In oFolder.Files If Not (oItem.Name = WScript.ScriptName OR oItem.Name = "index.html") Then oRst.AddNew() ' ファイル読み込み Dim oTextStream: Set oTextStream = g_oFso.OpenTextFile(g_sScriptDir&oItem.Name) Dim sText: sText = oTextStream.ReadAll oTextStream.Close() ' No oRst.Fields("no").Value = iCount ' ファイルパス oRst.Fields("path").Value = oItem.Name ' タイトル Dim sTitle: sTitle = GetTitle(sText) If Not sTitle = "" Then oRst.Fields("title").Value = sTitle ' 日時 Dim sDateTime: sDateTime = GetDateTime(sText) If Not sDateTime = "" Then oRst.Fields("datetime").Value = sDateTime ' URL Dim sUrl: sUrl = GetUrl(sText) oRst.Fields("url").Value = sUrl End If Next ' 日時の昇順 oRst.Sort = "datetime ASC" ' HTML出力 Dim oCreateFile: Set oCreateFile = g_oFso.CreateTextFile(g_sScriptDir&"index.html", True) oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("記事一覧") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") Dim iCount: iCount = 1 oRst.MoveFirst Do While Not oRst.EOF oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.WriteLine("") iCount = iCount + 1 oRst.MoveNext Loop oCreateFile.WriteLine("
Noファイル名投稿日時タイトルURL
"&iCount&""&oRst.Fields("path").Value&""&oRst.Fields("datetime").Value&""&oRst.Fields("title").Value&""&oRst.Fields("url").Value&"
") oCreateFile.WriteLine("") oCreateFile.WriteLine("") oCreateFile.Close() oRst.Close WScript.Echo "完了" '********************************************************* ' タイトル取得 '********************************************************* Function GetTitle(sText) GetTitle = "" Dim oRegExp: Set oRegExp = CreateObject("VBScript.RegExp") oRegExp.Pattern = "class="&Chr(34)&"entry_title"&Chr(34)&"[\s\S]+?

[\s\S]+?-->([\s\S]+?)