- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有很多 html 文件看起来像这样:
<font face="Garmond,Helvetica,Times" size="2" color="#330066">
<b>
Summary:
</b>
According to the complaint filed January 04, 2011, over a six-week period in December 2007 and January 2008, six healthcare related hedge funds managed by Defendant FrontPoint Partners LLC ("FrontPoint") sold more than six million shares of Human Genome Sciences, Inc. ("HGSI") common stock while their portfolio manager possessed material negative non-public information concerning the HGSI's clinical trial for the drug Albumin Interferon Alfa 2-a.
<br />
<br />
On March 2, 2011, the plaintiffs filed a First Amended Class Action Complaint, amending the named defendants and securities violations. On March 22, 2011, a motion for appointment as lead plaintiff and for approval of selection of lead counsel was filed. The defendants responded to the First Amended Complaint by filing a motion to dismiss on March 28, 2011.
<br />
<hr width="50%" align="left" />
INDUSTRY CLASSIFICATION:
<br />
<b>
SIC Code:
</b>
0000
<br />
<b>
Sector:
</b>
N/A
<br />
<b>
Industry:
</b>
N/A
<br />
</font>
我想做的是取出文件中间的文本并将其转换为人类可读的格式。在这个例子中,它是:
According to the complaint filed January 04, 2011, over a six-week period in December 2007 and January 2008, six healthcare related hedge funds managed by Defendant FrontPoint Partners LLC ("FrontPoint") sold more than six million shares of Human Genome Sciences, Inc. ("HGSI") common stock while their portfolio manager possessed material negative non-public information concerning the HGSI's clinical trial for the drug Albumin Interferon Alfa 2-a.
On March 2, 2011, the plaintiffs filed a First Amended Class Action Complaint, amending the named defendants and securities violations. On March 22, 2011, a motion for appointment as lead plaintiff and for approval of selection of lead counsel was filed. The defendants responded to the First Amended Complaint by filing a motion to dismiss on March 28, 2011.
我知道我必须做三件事,它们是:
"<br />"
与 "\n"
" "
与 " "
(一个空格)我知道后两件事很简单,只需使用 Python 中的 replace 方法即可,但我不知道如何实现第一个目标。
我知道一点正则表达式和BeautifulSoup,但我不知道如何将它们应用到这道题中。
有人可以帮助我吗?
谢谢,我很抱歉我的英语不好。
@Paul:我只想要一个摘要部分。我的老师(对计算机了解不多)给了我很多 html 文件,并要求我将它们转换为适合数据挖掘的格式(我的老师尝试使用 SAS 来做到这一点)。我不知道 SAS,但我认为它可能用于处理大量的 txt 文件,所以我想将这些 html 文件转换为普通的 txt 文件。
@Owen:我需要处理很多html文件,我觉得这个问题不太难处理,所以我想直接用Python解决。
最佳答案
你可以使用 Scrapely。
Scrapely is a library for extracting structured data from HTML pages. Given some example web pages and the data to be extracted, scrapely constructs a parser for all similar pages.
关于python - 如何将 html 文件转换为人类可读的 txt 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7155881/
有没有一种方法(程序、库)可以大致了解文档是用哪种语言编写的? 我有一堆混合语言的文本文档(~500K),需要导入支持 i18n 的 CMS (Drupal).. 我不需要完美的匹配,只需要一些猜测。
Closed. This question needs details or clarity。它当前不接受答案。
使用 UTF-8 编码。 (Multiple languages in one HTML page)。 跨不同浏览器(包括 iPad 上的 Safari)在单个网页上正确显示多种人类语言的最佳做法是什
我有一个完全可用的代码,它是为 Windows 编写的,是用 Visual Studio 构建的。 我想做的是为该软件添加另一种语言。我的想法是在窗口角落放置两个标志(一个英语和一个德语),并在用户点
我刚刚得到一个脚本,我想对其进行一些更改,我正在寻找某人为我开发一份自由职业,以使我将提供的加载字符串可读以进行编辑。 Lua代码是这样的: ------------------------- ENG
有没有不是简单逐字翻译的语言翻译项目?一个具有先进算法/设计的? 目前主流和流行的翻译软件,例如谷歌翻译,似乎是查找一个词或一组连续的词,然后将其直接翻译成不知何故确定为最佳匹配的内容。但是因为它不是
基于 Twilio 的人类/非人类检测 - 我正在尝试通过如下所示的代码来检测调用是否被人类或机器人接听 HashMap params = new HashMap(); params.put("Fro
这是目前(不确定)我能想到的处理多语言网站的最佳方式,它不涉及 gettext、zend_translate 或任何 php 插件或框架。 我认为它非常简单:我有 3 种语言,我将它们的“内容”写在不
我是一名优秀的程序员,十分优秀!