Python Web Scraping Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

It may seem odd that this does not also return the extension as part of the filename.  This is because we cannot assume that the content that we received actually matches the implied type from the extension.  It is more accurate to determine this using headers returned by the web server.  That's our next recipe.