If the same IP unified page access times within a short time, the system may be identified are reptiles, so using proxy IP can largely solve this problem
Commonly used agents are:
West stab free agents: www.xicidaili.com
Fast Acting: www.kuaidaili.com
Acting cloud: www.dailiyun.com
So how do we know whether the proxy IP has been successfully used it?
Very simple www.httpbin.org provides this function for us. You can see all the information submitted on our visit www.http.org, you can see the IP information we need on www.httpbin.org/ip, as shown in
So we started
We use the following free agents
Write code as follows
from urllib Import Request # does not use a proxy url = ' http://www.httpbin.org/ip ' RESP = request.urlopen (url) Print (resp.read ()) # Use proxy url = ' HTTP: // www.httpbin.org/ip ' # 1. use ProxyHandler, passing construct a proxy handler headler = request.ProxyHandler ({ ' HTTP ' : ' 223.244.45.134:65309 ' }) # 2. above construct using the handler to build a opner opner = request.build_opener (headler) # 3. opener used to send a request resp = opner.open(url) print(resp.read())
Need to import request library in python that comes with it is urllib
= request.ProxyHandler headler ({ 'HTTP': '223.244.45.134:65309'})
Note that ProxyHandler () parameter dictionary consisting of: HTTP and ip address above by the service provider, "65309" for the open The port number.
Run the following results
b'{\n "origin": "124.160.219.5"\n}\n' b'{\n "origin": "36.6.92.28"\n}\n'
That I use proxy ip success Note: There may be due to free agency ip instability leads to errors, after all, is always free to go wrong.
I have written above, if reproduced please indicate the source