我是linux的初学者。你能帮我把html页面转换成文本文件吗?该文本文件将从网页中删除所有图像和链接。我只想使用bash命令,而不是html到文本转换工具。作为一个例子,我想转换第一页谷歌搜索结果中的“计算机”。
谢谢
发布于 2012-09-15 08:01:00
我使用了python-boilerpipe,到目前为止,它工作得很好……
发布于 2012-09-14 18:57:53
最简单的方法是使用类似这样的转储(简而言之,是可视HTML的文本版本)。
远程文件:
lynx --dump www.google.com > file.txt
links -dump www.google.com
本地文件:
lynx --dump ./1.html > file.txt
links -dump ./1.htm
使用字符集转换为utf8 (see):
lynx -dump -display_charset UTF-8 ./1.htm
links -dump -codepage UTF-8 ./1.htm
发布于 2012-09-14 18:41:22
命令行上有html2text.py。
用法:html2text.py [(filename|url) [encoding]]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
--ignore-links don't include any formatting for links
--ignore-images don't include any formatting for images
-g, --google-doc convert an html-exported Google Document
-d, --dash-unordered-list
use a dash rather than a star for unordered list items
-b BODY_WIDTH, --body-width=BODY_WIDTH
number of characters per output line, 0 for no wrap
-i LIST_INDENT, --google-list-indent=LIST_INDENT
number of pixels Google indents nested lists
-s, --hide-strikethrough
hide strike-through text. only relevent when -g is
specified as well
https://stackoverflow.com/questions/12422289
复制相似问题