找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 28486|回复: 6

[格式转换] html2text 1.3.2a for Windows

[复制链接]
发表于 2012-11-24 18:33:04 | 显示全部楼层 |阅读模式
这是 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
发表于 2012-11-24 18:49:14 | 显示全部楼层
这个很不错 特别是处理小说的文本提取
发表于 2012-11-24 19:11:01 | 显示全部楼层
可以用 more 命令将单独的换行符处理为回车换行
 楼主| 发表于 2012-11-25 08:25:11 | 显示全部楼层
可以用 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
复制代码
发表于 2012-11-25 22:17:02 | 显示全部楼层
回复 3# CrLf


    超过6万多行之后more是不是会出问题
发表于 2012-11-25 23:41:30 | 显示全部楼层
回复 5# BAT-VBS

65535行,不仅如此,more 还会将 tab 处理为一定长度的空格,遇到文本结束符还会终止,好像对换页符也有特殊处理…那时候随口一说,没考虑这么多哈,find 应该是更好的选择
发表于 2015-10-19 12:51:26 | 显示全部楼层
可惜部分由乱码。。。


11楼. 每年都一样
==>
11楼. 每年都一&#18487;

2.七天,根本不足
==>
2.七天,&#18489;本不足
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 02:31 , Processed in 0.021283 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表