问题
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