import urllib.request, urllib.error, urllib.parse
request = urllib.request.Request('http://localhost:8080')
request.get_method = lambda : 'HEAD'
response = urllib.request.urlopen(request)
print(response.info())
Making HTTP HEAD request with urllib2 from Python 2