如何使用JSoup設置HTML標籤的屬性?使用JSoup設置HTML標籤的屬性
我想使用Jsoup庫在Java中設置標籤 - >「img」的屬性 - >「src」。
Elements img_attributes = doc.select("img[src^=/im]");
for(Element img_attribute: img_attributes)
{
String s = img_attribute.attr("src");
System.out.println(s);
}
此代碼打印src
值。 我想要更改src
值。
這是什麼庫? – TechSpellBound
@TechSpellBound:這裏的細節http://jsoup.org/ – krish
你有沒有嘗試過這樣的'Elements.attr(String key,String value)'? – sarcastyx