python http proxy 驗証

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('172.17.5.53', 80))
sock.send('GET http://www.google.com HTTP/1.1/r/nAccept-Encoding: identity/r/nHost: www.google.com/r/nProxy-Authorization: Basic bGs6MjAwMg==/r/nConnection: close/r/nUser-Agent: Python-urllib/2.6/r/n/r/n')
data = sock.recv(40960)

 

代理服務器 172.17.5.53 80

Authorization: Basic bGs6MjAwMg==

base64編碼 user:pwd base64.encodestring('lk:2002')


sckHTTP.httpProxyAddress = Proxy_IP
sckHTTP.httpProxyPort = Proxy_Port
sckHTTP.SetRequestHeader "Proxy-Authorization", "Basic " + EncodeBase64(app.ProxyUsername + ":" + app.ProxyPassword)


增加頭文件

self.headers['Proxy-Authorization'] = 'Basic bGs6MjAwMg=='


用代理和不用代理的區別

用代理

sock.connect(('172.17.5.53', 80))

GET http://www.google.com HTTP/1.1/r/n


不用代理

sock.connect(('www.google.com', 80))

GET / HTTP/1.1/r/n

 

你可能感兴趣的:(python,Stream,user,basic,authorization)