简体   繁体   English

JSoup运行非常慢

[英]JSoup runs very slow

I'm trying to use Jsoup to parse html from a website to extract img elements, but it runs very slowly 我正在尝试使用Jsoup从网站解析html以提取img元素,但是它运行非常缓慢

  try {
        Document doc = Jsoup.connect(webUrl).get();
        Elements imgElements = doc.select("img");
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

Log: Time run finish 11289.0 日志:时间运行完成11289.0

Jsoup loads the image over the internet so it will take as long as it takes to fetch the page over internet and parse it. Jsoup通过Internet加载图像,因此它花费的时间与通过Internet提取解析 页面所花费的时间一样长

You should try loading the page locally and from file and see if there's somekind of complexities in the document which causes the Jsoup to take a lot of time. 您应该尝试从本地和文件加载页面,并查看文档中是否存在某种复杂性,这会导致Jsoup花费大量时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM