我想將網站的內容讀入字符串中。我開始使用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();}然而,問題是,在這個網站中,當我使用 Chrome 等網絡瀏覽器時,它在其中一行中顯示:window.appPerformance.timeStamps['index.html']= Date.now();</script><primo-explore><noscript>JavaScript must be enabled to use the system</noscript><style>.init-message {所以我讀到jsoup對于這種情況沒有一個好的解決方案。有沒有什么好的方法來獲取這個頁面的元素,即使它使用了javascript?
使用android將web javascript內容解析為字符串
達令說
2023-07-06 14:53:00