【发布时间】:2019-12-23 11:34:39
【问题描述】:
我第一次使用 Jsoup 并尝试获取图片 URL,但似乎无法获取。
这是我要去的地方,但现在我有一个 JSON 格式的节点。 是否可以使用 JSOUP 仅获取 URL?
fun shouldParseHTML(url : String) {
var document = Jsoup.connect("https://boardgamegeek.com/boardgame/256788").get()
var scripts = document.body().select("script")
for (element : Element in scripts){
println("element" + element.childNode(0))
}
}
这就是它返回的内容
{
"@context": "http://schema.org",
"@type": "Product",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "7.37661",
"reviewCount": "242",
"bestRating": "10",
"worstRating": "1"
},
"image": "https://cf.geekdo-images.com/itemrep/img/TqDQErcijlN-gz8an0d7sm5AXUU=/fit-in/246x300/pic4783811.jpg",
"name": "Detective Club"
}
这是里面的元素:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "7.37661",
"reviewCount": "242",
"bestRating": "10",
"worstRating": "1"
},
"image": "https://cf.geekdo-images.com/itemrep/img/TqDQErcijlN-gz8an0d7sm5AXUU=/fit-in/246x300/pic4783811.jpg",
"name": "Detective Club"
}
</script>
谢谢;D
【问题讨论】:
标签: android html json kotlin jsoup