本帖最后由 WHY 于 2018-12-13 16:30 编辑
回复 43# lxh623
zgshige.bat- @echo off
- echo %time%
- set "htmlPath=E:\zgshige"
- dir /b /s "%htmlPath%\*.html" > List.txt
- PowerShell -exec ByPass -f "zgshige.PS1" List.txt
- del List.txt
- echo %time%
- pause
复制代码 zgshige.ps1- param([String]$ListFile);
- $MyPath = $MyInvocation.MyCommand.Path -replace '[^\\]+$';
-
- forEach ($file In (type $ListFile -ReadCount 0)) {
- $str = [IO.File]::ReadAllText($file, [Text.Encoding]::UTF8);
- $arr = $str -split '<div class="(?:text-center b-b b-2x b-lt|col-xs-12 hidden-sm[^"]*)">';
- If ($arr.Count -eq 3) {
- $s = $arr[1] -replace '<h3>(?!TTT)', '$&TTT'; #标题前面加 TTT
- $s = $s -replace '(?<!\r)\n', "`r`n";
- $s = $s -replace '<div class="(signature|m-lg font14|note)">|</?br>|<br/>|</p>', '<br />';
- $s = $s -replace '<!--(?:(?!-->)[\s\S])*-->| '; #删除注释标签和转义空格
- $s = $s -replace '<(?!br|/?h3)[^>]*>'; #保留换行标签和h3标签
- $s = $s -replace '(<br />)+', '$1';
- $s = $s -replace '(?m)^\s+'; #删除行首空格
- $name = ($file -split '\\')[-2] + '.Log';
- [IO.File]::AppendAllText($MyPath + $name, $s + "`r`n", [Text.Encoding]::UTF8);
- }
- }
复制代码
|