开发者

Using python (urllib) to download a file, how to get the real filename?

开发者 https://www.devze.com 2023-03-14 21:47 出处:网络
So I finally managed to get my script to login to a website and download a file... however, in some instances I will have a url like \"http://www.test.com/index.php?act=Attach&type=开发者_高级运维

So I finally managed to get my script to login to a website and download a file... however, in some instances I will have a url like "http://www.test.com/index.php?act=Attach&type=开发者_高级运维post&id=3345". Firefox finds the filename ok... so I should be able to.

I am unable to find the "Content-Disposition" header via something like remotefile.info()['Content-Disposition']

Also, remotefile.geturl() returns the same url.

What am I missing? How do I get the actual filename? I would prefer using the built-in libraries.


It is the task of the remote server/Service to provide the content-disposition header.

There is nothing you can do unless the remote server/service is under your own control..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号