使用 Jsoup 解析数据

Parse data with Jsoup

我有包含此数据的字符串:

<div>
  <a href='https://www.some.html'>
    <img src='https://besttv232.jpg' alt='null' title='null' border='0' width='100' height='56'>
  </a>
</div>
Some text is also over here

我需要用 Jsoup 解析它,我需要 href url、img url 和数据(一些文本...)

我试过:

Document doc = Jsoup.parse(myData); //myData is string with content above
Elements links = content.get("div");

for (Element link : links) {
    String linkHref = link.attr("href");
    String linkHrefa = link.attr("img");
    String linkText = link.text();
}

I need the a href url

Element a = doc.select("a").first();
String src = a.attr("href");

img url

Element img = doc.select("img").first();
String src = img.attr("src");

data

String content = doc.body().text();