我如何使用Perl将Lyn呈现为文本格式? [英] How can I render HTML as text using Perl as Lynx does?
问题描述
可能存在重复:
你推荐哪种CPAN模块将HTML转换为纯文本?
问题:
- 是否有模块呈现HTML 收集文本,同时遵守字体样式标签,例如
< tt>
,< b> / code>,
< i>
等和分行< br>
,类似于 Lynx 。
例如:
#cat test.html
< body>
< div id =fooclass =blah>
< tt>测试< br>
< b>测试< / b>< br>
无论< br>
测试< / tt>
< / div>
< / body>
注意:第二行应该是粗体。 Lynx是一个很大的程序,它的html渲染将不是微不足道的。 这个怎么样: Possible Duplicate:
For example: Note: the second line should be bold. Lynx is a big program and its html rendering will be non trivial. How about this:
这篇关于我如何使用Perl将Lyn呈现为文本格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!#lynx.exe --dump test.html $ c
$ b $ / $ c $
my $ lynx ='/ path / to / lynx';
my $ html = [html here];
my $ txt =`$ lynx --dump --width 9999 -stdin <
`;
Which CPAN module would you recommend for turning HTML into plain text? Question:
<tt>
, <b>
, <i>
, etc and break-line <br>
, similar to Lynx. # cat test.html
<body>
<div id="foo" class="blah">
<tt>test<br>
<b>test</b><br>
whatever<br>
test</tt>
</div>
</body>
# lynx.exe --dump test.html
test
test
whatever
test
my $lynx = '/path/to/lynx';
my $html = [ html here ];
my $txt = `$lynx --dump --width 9999 -stdin <<EOF\n$html\nEOF\n`;