#_*_coding:utf-8_*_
import urllib2
def GetHttpData(url,proxy):
proxy_handler=urllib2.ProxyHandler({'http':proxy})
opener=urllib2.build_opener(proxy_handler,urllib2.HTTPHandler)
try:
response=opener.open(url,timeout=10)
html = response.read()
return html
except urllib2.HTTPError,e:
print 'Error code:',e.code
except urllib2.URLError,e:
print 'Reason:',e.reason
if __name__=="__main__":
# 访问的目标地址
url='http://music.baidu.com/artist/1100'
#免费匿名服务器
proxy='41.77.173.79:80'
html = GetHttpData(url,proxy)
print html
浙公网安备 33010602011771号