gpt4 book ai didi

java - 使用 Jsoup 获取元标记值

转载 作者:行者123 更新时间:2023-12-02 00:59:19 26 4
gpt4 key购买 nike

我需要从所有元标记中获取一个值:

Elements elements= document.getElementsByTag("meta");

我将得到这些元素:

<meta name="twitter:image" content="https://lh3.googleusercontent.com/0daLqxVdiOGXvHI1R5aUFf_6znVlBHMturM9SXnpOQagADdYJDycyPzT-btcntR4jW4=w600-h300-pc0xffffff-pd">
<meta name="appstore:developer_url" content="http://www.verylittlenightmares.com">
<meta name="appstore:bundle_id" content="eu.bandainamcoent.verylittlenightmares">
<meta name="appstore:store_id" content="eu.bandainamcoent.verylittlenightmares">
<meta itemprop="price" content="200,00&nbsp;$">
<meta itemprop="url" content="https://play.google.com/store/apps/details?id=eu.bandainamcoent.verylittlenightmares&amp;rdid=eu.bandainamcoent.verylittlenightmares&amp;feature=md&amp;offerId">

如何从此属性获取值 (200,00 $)?

<meta itemprop="price" content="200,00&nbsp;$">

最佳答案

您可以这样做,无需迭代所有 meta 元素,假设您只有一个带有 itemprop=price 的节点:

Element meta = doc.select("meta[itemprop=price]").first();        
System.out.println(meta.attr("content"));

输出为所需的 200,00 $'。

关于java - 使用 Jsoup 获取元标记值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60916391/

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