簡體   English   中英

我只能用Kotlin獲取html源代碼的div嗎?

[英]Can I only get the div of a html source code with Kotlin?

我正在創建一個應用程序,它將使用此頁面的div https://gyp.ch/ecran/來顯示它。

我試圖用Kotlin找到getElementByID的方法,但我不認為這是因為JVM。

logo.setOnClickListener {
 "https://gyp.ch/ecran/".httpGet().responseString{request,response,result ->
  profs.text = result.get()
 }
}

It just displays the result.get() so in this case the code source of the link above.

由於您使用的是kotlin,因此可以輕松地將jsoup添加到項目中。

implementation 'org.jsoup:jsoup:1.11.3'

簡單的例子 -

Document doc = Jsoup.connect("https://gyp.ch/ecran/").get();
log(doc.title());
Elements allDivs = doc. getElementsByTag("div");
for (Element div : allDivs) {
 div.text()
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM