这个在windows上软件是一大把,很易用的。经过一些时间的摸索现将经验写下来,以节省有这个需要的朋友的时间。
我下载是用firefox下的扩展downthemall来批量下载的,这个我就不说了。
下面说下html2text的使用说明
代码: 全选
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>
将输入重新输出至 <file>
-nobs Do not use backspaces for boldface and underlining
这个选项要用着。不然的话转换后的文件 里会有很多没用的符号
-ascii Use plain ASCII for output instead of ISO-8859-1
用了如下命令
假若要1.html 转换为2.txt
代码: 全选
html2text -o 2.txt -nobs 1.html
虽然转化单个文件是功了。但是要批量转化怎么办
这里shell脚本的威力显现出来了
新建一个文件文件 就叫html2text.sh吧,里面的内容如下。不用详细解释这个脚本了。
代码: 全选
#!/bin/bash
ls *.html |while read i
do html2text -o $i.txt -nobs $i
done
然后保存后加上可执行
代码: 全选
chmod +x html2text.sh
