HTML数据提取

发布于 2024-09-19 15:45:54 字数 211 浏览 3 评论 0 原文

我正在访问一些网站,我需要提取一些数据。更具体地说 - 从这部分开始:

<input type="hidden" value="1" name="d520783895194bd08750e47c744d553d">

我需要提取“名称”部分。我听说正则表达式不是最好的解决方案,所以我想问一下访问我需要的这段数据的最佳方式是什么。

I'm accessing some website and I need to extract some data. To be more specific - from this part:

<input type="hidden" value="1" name="d520783895194bd08750e47c744d553d">

I need to extract the "name" part. I heard that reular expressions are not the best solution, so I'd like to ask what is the best way to access this piece of data I need.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坠似风落 2024-09-26 15:45:54

使用 NekoHTML 或 TagSoup 解析网站后(应该注意您的输入字段标记未关闭的事实),我建议使用 xpath 表达式:

//input[@type='hidden'][@value=1]/@name

在 groovy 中,您将以 GPath

After parsing a website with NekoHTML or TagSoup (which should take care of the fact that your input field tag is not closed), I suggest to use a xpath expression:

//input[@type='hidden'][@value=1]/@name

In groovy you will apply it in form of GPath.

淡写薰衣草的香 2024-09-26 15:45:54

使用 Html 解析库,他们可以修复格式错误的 Html,从而可以轻松导航文档以查找和更新元素。以下是 Java/Groovy 实现列表的链接:

http://www.wavyx.net/2009/01/13/looking-for-a-java-html-parser-or-groovy/

看起来像 NekoHTMLTagSoup 很流行,但我没有使用过任何一个或 Groovy。但我在其他语言中使用过 Html 解析器。

Use a Html parsing library, they fix malformed Html a make it easy to navigate the document to find and update elements. Here is a link to a list of Java/Groovy implementations:

http://www.wavyx.net/2009/01/13/looking-for-a-java-html-parser-or-groovy/

Looks like NekoHTML and TagSoup are popular, but I haven't used either or Groovy for that matter. But I have used Html Parsers in other languages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文