【发布时间】:2015-08-13 23:07:32
【问题描述】:
我正在开发一项用 Python 编写的服务,该服务有时会从给定的 URL 下载图像并将它们存储在服务器上。
此服务会检查从 URL 返回的内容类型,并且仅在内容类型为“image/jpeg”等时才下载图像。
我最近遇到了以下 URL 的一个有趣问题: http://www.nationaldentalreviews.org/Handlers/ImageDisplay.ashx?qUID=8597&qType=__ProfileMicroSite
此 URL 在浏览器中打开时会显示某种编码字符串。
当用作图像标签的“src”时,它会渲染图像。
<html>
<body>
<img src = 'http://www.nationaldentalreviews.org/Handlers/ImageDisplay.ashx?qUID=8597&qType=__ProfileMicroSite'>
</body>
</html>
此 URL 的 content-type 是 text/html
在 Python 中,有什么方法可以让我确定此 URL 指向可用作“src”的图像吗?
【问题讨论】:
-
你的 Python 版本是多少?
标签: image python-2.7 encoding