from urllib import request """ 使用代理 """ url = "http://httpbin.org/ip" #设置代理的服务器的ip和端口,以及协议类型 handler = request.ProxyHandler({"http":"121.232.194.71:9000"}) opener = request.build_opener(handler) resp = opener.open(url) print(resp.read())