![](/img/trans.png)
[英]How to extract bold content using jsoup from various html pages of different types of bold html expression?
[英]Extract JS Libraries from HTML content using Java/Jsoup
頁面: https : //en.wikipedia.org/wiki/Punjab,_India
HTML 源供參考(使用 Chrome) : view-source:https://en.wikipedia.org/wiki/Punjab,_India
使用上面的頁面 URL,我想提取 HTML 中使用的所有 javascript 庫。
是否有使用Jsoup/Java或任何其他可以使用的 Java 庫的簡單方法。
您可以嘗試以下簡單的解決方案:
List<String> sources = Jsoup.parse(html)
.select("script")
.stream()
.map(element -> element.attr("src"))
.filter(src -> !StringUtil.isBlank(src))
.collect(Collectors.toList());
對您來說可能就足夠了。 如果沒有,請說明您期望什么輸出。
在我看來,您想從html頁面提取一些數據。 我建議您看一下此框架https://github.com/GoogleChrome/puppeteer/blob/v1.10.0/docs/api.md#,但是您必須遍歷DOM才能提取信息。 可以幫助解決此問題的另一個框架是https://jquery.com/ 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.