import urllib.request, urllib.error, urllib.parse
from urlgrabber.keepalive import HTTPHandler
keepalive_handler = HTTPHandler()
opener = urllib.request.build_opener(keepalive_handler)
urllib.request.install_opener(opener)
Python urllib2 with keep alive