gpt4 book ai didi

java - 用于响应的 HTML 解析器 - Java

转载 作者:行者123 更新时间:2023-11-30 06:32:22 26 4
gpt4 key购买 nike

我正在使用 HttpClient 访问特定网站,我得到的响应是 HTML 格式的。我应该使用哪个解析器或方法解析 HTML 并从响应中获取我想要的内容。注意:我在 Java 中使用 HttpClient

最佳答案

使用jsoup .

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

jsoup implements the WHATWG HTML5 specification, and parses HTML to the same DOM as modern browsers do.

  • scrape and parse HTML from a URL, file, or string
  • find and extract data, using DOM traversal or CSS selectors
  • manipulate the HTML elements, attributes, and text
  • clean user-submitted content against a safe white-list, to prevent XSS attacks
  • output tidy HTML

jsoup is designed to deal with all varieties of HTML found in the wild; from pristine and validating, to invalid tag-soup; jsoup will create a sensible parse tree.

关于java - 用于响应的 HTML 解析器 - Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8811640/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com