
问题描述:
我喜欢看电子书,可是给txt下载的不多,请教大家有没有这样的转换工具?
解析:
这种软件比较多:
如
HTML2TXT [HTML到TXT转换器]是一个可以帮助您将HTML文件转换为TXT格式的免费软件工具.它不仅删除HTML标签,而且重新格式化文本,使文本更具可读性.支持鼠标拖放文件进行转换.它能在短短壹分钟内转换成百上千个文件,而且支持多个文件同时转换.如果您配合CHMUnpacker [CHM解包器]使用,效果更佳。
复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起运行
<# :@echo off
rem 提取html内的文字内容输出到txt文件并截取部分指定内容作为文件名
set #=Any question&set @=WX/&set $=Q&set/az=0x53b7e0b4
title %#% +%@%%$%%$% %z%
set "rootpath=%~dp0"
if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
cd /d "%rootpath%"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
echo%#% +%@%%$%%$% %z%
pause
exit
#>
$result=$args[0]+'\#convert'
if(-not (test-path -liter $result)){[void](md $result -force)}
$Utf8NoBom=New-Object System.Text.UTF8Encoding $False
$files=@(dir -liter $args[0]|?{('.html' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])})
$c=$files.length.toString()
$t=[math]::pow(10,$c.length)
$d=(get-date).toString('yyyyMMdd')
for($i=0$i -lt $files.length$i++){
write-host $files[$i].Name
$bin=[IO.File]::ReadAllText($files[$i].FullName, $Utf8NoBom)
$html=New-Object -ComObject 'HTMLFile'
$html.designMode='on'
$html.IHTMLDocument2_write($bin)
$text=$html.body.innerText -replace '\s+(?=账号统计|用户动态)',"`r`n"
$filename=$d+' '+$c+'-'+($t+$i+1).toString().Substring(1)+' '
$name=[regex]::match($text,'真实姓名[::]([^\r\n]+)')
if($name.success){$filename+=(($name.groups[1].value.trim() -replace '先生','男') -replace '小姐|女士','女')+' '}
$birth=[regex]::match($text,'出生日期[::](\d+)年(\d+)月(\d+)日')
if($birth.success){$filename+=($birth.groups[1].value+''+(100+[int]$birth.groups[2].value).toString().Substring(1)+''+(100+[int]$birth.groups[3].value).toString().Substring(1))+' '}
$telephone=[regex]::match($text,'固定电话[::]([^\r\n]+)')
if($telephone.success){if($telephone.groups[1].value.trim() -ne '无'){$filename+=($telephone.groups[1].value.trim())+' '}}
$mobilephone=[regex]::match($text,'手机[::]([^\r\n]+)')
if($mobilephone.success){if($mobilephone.groups[1].value.trim() -ne '无'){$filename+=($mobilephone.groups[1].value.trim())+' '}}
$region=[regex]::match($text,'所在地区[::]([^\r\n]+)')
if($region.success){if($region.groups[1].value.trim() -ne '无'){$filename+=($region.groups[1].value.trim())+' '}}
$company=[regex]::match($text,'所在公司[::]([^\s]+)')
if($company.success){if($company.groups[1].value.trim() -ne '无'){$filename+=($company.groups[1].value.trim())}}
$filename+='.txt'
[IO.File]::WriteAllText($result+'\'+$filename, $text, [Text.Encoding]::Default)
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)