擅长:python、mysql、java
<p>您可以发出<code>head</code>请求来检查<code>url</code>的内容类型。头部请求不会下载正文内容。
使用python<a href="http://docs.python-requests.org/en/latest/" rel="nofollow">requests</a>模块的示例:</p>
<pre><code>>>> import requests
>>> url = "https://encrypted-tbn1.gstatic.com/images?q=tbn%3AANd9GcTwC6cNpAen5dgGgTmmH2SG75xhvTN-oRliaOgG-3meNQVm-GdpUu7SQX5wpA"
>>> h = requests.head(url)
>>> print h.headers.get('content-type')
image/jpeg
</code></pre>