我如何使用Perl将Lyn呈现为文本格式? [英] How can I render HTML as text using Perl as Lynx does?

查看:156
本文介绍了我如何使用Perl将Lyn呈现为文本格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

你推荐哪种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.exe --dump test.html






$ b $ / $ c $

注意:第二行应该是粗体。

解决方案

Lynx是一个很大的程序,它的html渲染将不是微不足道的。



这个怎么样:

  my $ lynx ='/ path / to / lynx'; 
my $ html = [html here];
my $ txt =`$ lynx --dump --width 9999 -stdin <EOF\\\
`;


Possible Duplicate:
Which CPAN module would you recommend for turning HTML into plain text?

Question:

  • Is there a module to render HTML, specifically to gather the text, while adhering to font-style tags, such as <tt>, <b>, <i>, etc and break-line <br>, similar to Lynx.

For example:

# 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

Note: the second line should be bold.

解决方案

Lynx is a big program and its html rendering will be non trivial.

How about this:

my $lynx = '/path/to/lynx';
my $html = [ html here ];
my $txt = `$lynx --dump --width 9999 -stdin <<EOF\n$html\nEOF\n`;

这篇关于我如何使用Perl将Lyn呈现为文本格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆