vba - Excel - 使用 VBA 抓取 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
.
我已经搜索并尝试了许多不同的东西,但我无法找到一种方法来显示它以便于阅读。
该网页位于我们的工作 Intranet 上,并且有一个登录(使用电子表格的多人将使用该登录 - 所以我无法自动执行此操作)
首选输出示例:
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.
任何意见,将不胜感激。
解决方案
也许,在每次出现一个句点后添加一个换行符?
例如replace
,"."
与"." & vbCrLf
推荐阅读
- haskell - 为什么这个 Haskell 函数中没有一个普遍量化的变量?
- c# - ASP.NET Core React 项目模板 - 如何链接到 C# 后端
- python - Ctypes:OSError:异常:堆栈溢出
- python - 在唯一元素的结构化 Numpy 数组中查找相邻值的最简单方法是什么?
- ionic-framework - 如何将 Phaser 3 集成到 Ionic 4?
- sql-server - 如何选择 SQL Server 表作为制表符分隔的字符串
- javascript - 当实际的鼠标点击没有在目标元素上开始时,如何防止触发点击事件?
- flutter - 如何在 Dart 中获取某物的类型?
- java - 文件中的允许值
- java - 使用 String.parseByte(string s) 处理 0x7F 以上的值 - Java