我想將網(wǎng)站的內(nèi)容讀入字符串中。我開(kāi)始使用jsoup如下:private void getWebsite() { new Thread(new Runnable() { @Override public void run() { final StringBuilder builder = new StringBuilder(); try { String query = "https://merhav.nli.org.il/primo-explore/search?tab=default_tab&search_scope=Local&vid=NLI&lang=iw_IL&query=any,contains,???? ????"; Document doc = Jsoup.connect(query).get(); String title = doc.title(); Elements links = doc.select("div"); builder.append(title).append("\n"); for (Element link : links) { builder.append("\n").append("Link : ").append(link.attr("href")) .append("\n").append("Text : ").append(link.text()); } } catch (IOException e) { builder.append("Error : ").append(e.getMessage()).append("\n"); } runOnUiThread(new Runnable() { @Override public void run() { tv_result.setText(builder.toString()); } }); } }).start();}然而,問(wèn)題是,在這個(gè)網(wǎng)站中,當(dāng)我使用 Chrome 等網(wǎng)絡(luò)瀏覽器時(shí),它在其中一行中顯示:window.appPerformance.timeStamps['index.html']= Date.now();</script><primo-explore><noscript>JavaScript must be enabled to use the system</noscript><style>.init-message {所以我讀到j(luò)soup對(duì)于這種情況沒(méi)有一個(gè)好的解決方案。有沒(méi)有什么好的方法來(lái)獲取這個(gè)頁(yè)面的元素,即使它使用了javascript?
使用android將web javascript內(nèi)容解析為字符串
達(dá)令說(shuō)
2023-07-06 14:53:00