urllib2中使用http、https代理 - liukeforever的专栏 - 博客频道 - CSDN.NET
urllib2中使用http、https代理
proxy=urllib2.ProxyHandler({'https': 'http://lk:2002@172.17.5.53:80'})
opener=urllib2.build_opener(proxy)
urllib2.install_opener(opener)proxy=urllib2.ProxyHandler({'http': 'http://lk:2002@172.17.5.53:80'})
opener=urllib2.build_opener(proxy)
urllib2.install_opener(opener)>>> urllib2.urlopen('https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=monkey&as_filetype=png&imgtype=clipart&imgc=color&rsz=8')
send: 'GET https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=monkey&as_filetype=png&imgtype=clipart&imgc=color&rsz=8 HTTP/1.1/r/nAccept-Encoding: identity/r/nHost: ajax.googleapis.com/r/nProxy-Authorization: Basic bGs6MjAwMg==/r/nConnection: close/r/nUser-Agent: Python-urllib/2.6/r/n/r/n'
reply: 'HTTP/1.0 200 OK/r/n'
header: Content-Type: text/htmlheader: Refresh: 0; URL=https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=monkey&as_filetype=png&imgtype=clipart&imgc=color&rsz=8