有哪些好的 Java 库可以用于搜索和从网页中抓取数据。
有哪些好的开源 Java 库可以从网页中搜索和抓取数据并将其粘贴到数据库中。例如,假设我有一个页面,例如:
<tr><td><b>Address:</b></td>
<td colspan=3>123 My Street </td></tr>
“地址:”是关键,但我实际上试图获取“123 My Street”,其中有一堆 html 标签和中间的空格。理想情况下,我想获取字符串“Address:”后面的 td 之间的值。似乎 JSoup 可以进行查找,但我没有看到关于如何进行偏移的好示例(我可能错过了)。是否有处理键/值的库?
我还有兴趣了解任何类似于 Kapow Extraction Browser 的 UI 脚本开源 (MIT/Apache) 计划。
谢谢。
What are some good open source java libraries to search and scrape data out of a web page and stick it into a database. For example, suppose I had a page such as:
<tr><td><b>Address:</b></td>
<td colspan=3>123 My Street </td></tr>
"Address:" is the key, but I'm actually trying to get "123 My Street" which has a bunch of html tags and spaces in between. Ideally I want to get the value between the td that follows the string "Address:". It seems like JSoup can do the find, but I didn't see a good example on how to do the offset (I may have missed it). Is there a library that handles key/value?
I'd also be interested in learning about any open source (MIT/Apache) initiatives for UI scripting similar to the Kapow Extraction Browser.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试Web-Harvest。
它是用 Java 编写的开源爬虫。
它可以用作 Java 库、命令行应用程序或与其独立的 IDE 一起使用。
您可以使用
元素来提取XHTML 文档中的任何值。Try Web-Harvest.
It's open-source crawler written in Java.
It can be used as Java library, as command-line application or with it's standalone IDE.
You can use
<xpath>
element to extract any value from the XHTML document.这是一个很好的开源解析器列表: http://java-source.net/open -source/html-parsers
我使用了 TagSoup 效果很好成功解析数万个网页在野外。至于“键值”关系,那是你必须自己处理的事情。
This is a good list of open source parsers: http://java-source.net/open-source/html-parsers
I've used TagSoup with great success for parsing tens of thousands of web pages in the wild. As for the "key-value" relationship, that's something you'll have to deal with yourself.