requests the library to verify how the proxy is valid

Now you want to access a destination address is http address: http: //icanhazip.com/, this address can be obtained outside the network ip machine

theory, since the address is http, it will use the http proxy to access the address via a proxy, i.e.

RES = requests.get ( 'http://icanhazip.com/', Proxies = { 'HTTP': 'adcd.websd.zdw.vdm.tded: 8080'})

Print res.content

the print address is the agent machine ip, ip instead of the machine, the agent effective

 

if proxy with https, although they would request succeeds, but the actual agency did not go, but with direct access to the machine, that is

res = requests.get ( 'http : //icanhazip.com/ ', Proxies = {' HTTPS ':' adslsdfsdfspider01.wsdfeb.zwsdf.tsdfed: 9090 '})

Print res.content

print out the result of the present machine is ip

 

but strangely, if I into the form

res = requests.get ( 'http://icanhazip.com/', proxies = { 'http': 'adslspidsdfsdfer01.sdfweb.zsdfw.tesdfsdfsdd: 9090'})

that is key or http, but the value I https address, then not only the success of the request, and a proxy IP machine, instead of a native IP, i.e. agents Effective

 

analysis of the reasons :( course, in fact, just a guess, but pretty close)

requests command will first determine which proxies parameters passed key (http / https), to see if it is consistent with the target url protocol, such as if the url is http, which is also the incoming http proxies of the key, or with https then the time is , requests will be considered an effective agent, visit this url will come through a proxy. If the url is http, but the key is https, or url is https, but the key is http, then requests will think they do not match, you will directly go to visit the destination address without proxy.

A special case is that if the url is http, proxies http is the key, but the key of the value I pass https proxy requests at this time due to the discovery protocol is the same, it will also be requested through a proxy, this time due to the company the https proxy can handle the http request, the agent success.

 

wget download page when using a proxy and requests principles are the same. Are based on key agreements are consistent and url use a proxy to determine whether the

original link: https: //blog.csdn.net/u011734144/article/details/71707443

Guess you like

Origin www.cnblogs.com/yoyowin/p/12483688.html