Board logo

标题: [格式转换] html2text 1.3.2a for Windows [打印本页]

作者: tmplinshi    时间: 2012-11-24 18:33     标题: html2text 1.3.2a for Windows

这是 http://www.mbayer.de/html2text/ 的 Windows 版本,提取自 http://www.opencats.org/downloads/setupResumeIndexingTools.exe

This is html2text, version 1.3.2a

Usage:
  html2text -help
  html2text -version
  html2text [ -unparse | -check ] [ -debug-scanner ] [ -debug-parser ] \
     [ -rcfile <file> ] [ -style ( compact | pretty ) ] [ -width <w> ] \
     [ -o <file> ] [ -nobs ] [ -ascii ] [ <input-url> ] ...
Formats HTML document(s) read from <input-url> or STDIN and generates ASCII
text.
  -help          Print this text and exit
  -version       Print program version and copyright notice
  -unparse       Generate HTML instead of ASCII output
  -check         Do syntax checking only
  -debug-scanner Report parsed tokens on STDERR (debugging)
  -debug-parser  Report parser activity on STDERR (debugging)
  -rcfile <file> Read <file> instead of "$HOME/.html2textrc"
  -style compact Create a "compact" output format (default)
  -style pretty  Insert some vertical space for nicer output
  -width <w>     Optimize for screen widths other than 79
  -o <file>      Redirect output into <file>
  -nobs          Do not use backspaces for boldface and underlining
  -ascii         Use plain ASCII for output instead of ISO-8859-1


示例:
C:\>curl http://www.gnu.org/software/sed/manual/sed.html | html2text -style pretty -nobs | sed !d >sed.txt


因为 html2text 输出的行只有换行符,没有回车符,所以可以用 sed 转换一下。

http://bcn.bathome.net/s/tool/index.html?key=html2text
作者: HMPT    时间: 2012-11-24 18:49

这个很不错 特别是处理小说的文本提取
作者: CrLf    时间: 2012-11-24 19:11

可以用 more 命令将单独的换行符处理为回车换行
作者: tmplinshi    时间: 2012-11-25 08:25

可以用 more 命令将单独的换行符处理为回车换行
CrLf 发表于 2012-11-24 19:11



谢谢!经测试,more 命令会在末尾增加一行空行:
  1. curl nircmd.nirsoft.net | html2text -nobs | more >test_more.txt
复制代码
还可以用 find 命令:
  1. curl nircmd.nirsoft.net | html2text -nobs | find /v "" >test_find.txt
复制代码

作者: BAT-VBS    时间: 2012-11-25 22:17

回复 3# CrLf


    超过6万多行之后more是不是会出问题
作者: CrLf    时间: 2012-11-25 23:41

回复 5# BAT-VBS

65535行,不仅如此,more 还会将 tab 处理为一定长度的空格,遇到文本结束符还会终止,好像对换页符也有特殊处理…那时候随口一说,没考虑这么多哈,find 应该是更好的选择
作者: shuzai    时间: 2015-10-19 12:51

可惜部分由乱码。。。


11楼. 每年都一样
==>
11楼. 每年都一䠷

2.七天,根本不足
==>
2.七天,䠹本不足




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2