我有一些设计糟糕的HTML,我试图从这些HTML中抓取数据,使其易于阅读。
我可以使用innerHTML
来获取信息,但不幸的是,它变成了一堵文本墙。
当我“查看源代码”(为了保护隐私而更改单词)时,来自网页的源代码的示例是:
<td nowrap valign="top"><b>Logger Notes</b></td>
<td valign="top">Hi,
Person needs a full breakdown Important information.
Would also would like confirmation in a letter about what kinds of assistance
she is not eligible for if possible.
Would prefer sent to email.
Thanks </td>
然而,当我获得数据时,它会像这样变成一堵文本墙:
Hi, Person needs a full breakdown Important information. Would also would like confirmation in a letter about what kinds of assistance she is not eligible for if possible. Would prefer sent to email. Thanks
这显然很难读懂。
当我使用innerHTML
查看字符串时,所有换行符实际上都是空格字符,所以我不能使用replace
。
我搜索并尝试了许多不同的东西,但我想不出一种方法来显示它,使它易于阅读。
该网页在我们的工作内联网上,并且有一个登录(多个使用电子表格的人将使用-所以我不能自动化)
首选输出示例:
Hi,
Person needs a full breakdown Important information.
Would also would like confirmation in a letter about what kinds of assistance she is not eligible for if possible.
Would prefer sent to email.
任何建议都将不胜感激。
发布于 2018-09-04 07:15:04
也许,在每次出现句点后添加一个换行符?
例如,使用"." & vbCrLf
replace
"."
https://stackoverflow.com/questions/52156349
复制相似问题