gpt4 book ai didi

java - 网页的上次修改和大小

转载 作者:行者123 更新时间:2023-12-02 08:08:03 25 4
gpt4 key购买 nike

我想问如何获取网页的最后修改日期和大小(如500KB)?对于修改日期:我尝试了很多网页,但都返回0。例如

URL url = new URL(htmlList.elementAt(i));
URLConnection connection = url.openConnection();
connection.connect();
time = connection.getLastModified();

最佳答案

您可以获得Content-Length header 或大小。 connection.getContentLength()

动态页面可能没有设置Last-Modified header ,但无论如何都可以尝试一下(例如,Stackoverflow设置了它)。如果为 0,则假定为当前时间。

关于java - 网页的上次修改和大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7860316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com