Get size of a file before downloading in Python

前端 未结 8 1270
名媛妹妹
名媛妹妹 2020-12-02 06:56

I\'m downloading an entire directory from a web server. It works OK, but I can\'t figure how to get the file size before download to compare if it was updated on the server

8条回答
  •  温柔的废话
    2020-12-02 07:41

    Also if the server you are connecting to supports it, look at Etags and the If-Modified-Since and If-None-Match headers.

    Using these will take advantage of the webserver's caching rules and will return a 304 Not Modified status code if the content hasn't changed.

提交回复
热议问题