Download file from url that doesn't end with .extension [closed]

送分小仙女□ 提交于 2019-12-26 04:55:16

问题


I've seen examples on how to download files programmatically, but they all use direct links, ending with .txt .mp3 .jpg, whatever. However, the link to the file I want to download isn't a direct link: it doesn't end with .extension. How can you download the file in this case?


回答1:


When downloading over HTTP, the file name is usually set by the server in Content-Disposition header. If that is not present, it is up to the client to choose the file name (based on the URL or some other strategy). The extension can often be derived from the Content-Type response header. See this for some of standard content types http://en.wikipedia.org/wiki/Internet_media_type




回答2:


Very stupid answer: You can just download it as all other files. Download it the same way as you do with urls with extensions.



来源:https://stackoverflow.com/questions/19367551/download-file-from-url-that-doesnt-end-with-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!