Python's Generation _ Manager

Source: Internet
Author: User

1. Reference Tor?

http://docs.python-requests.org/en/master/user/advanced/

Using Python ' s URLLIB2 or requests with a SOCKS5 proxy

Two methods of request using SOCKS5 Proxy in Python (personal recommendation Method II)

How to make Python requests work via SOCKS Proxy

Connecting to a SOCKS Proxy within Python

Should you want to use the SOCKS proxy only with urllib2 then the wrapmodule can used. This replaces a module ' s socket library with a SOCKS socket[2].

What are the new SOCKS5 proxy settings options in the v3.2.0 release?

This predecessor agent, should be to the Shadowsocks.exe itself proxy settings, make it to go to a proxy. Because some companies, the intranet environment requires agents to access the extranet.

The difference between HTTP,SOCKS4,SOCKS5 agents

HTTP proxy: The ability to proxy client HTTP access, mainly proxy browser access to the Web page, its port is generally 80, 8080, 3128 and so on;
Socks Proxy: Socks Proxy Unlike other types of proxies, it simply passes the packet without caring about what application protocol, which can be an HTTP request, so the SOCKS proxy server is much faster than other types of proxy servers. Socks agents are divided into SOCKS4 and SOCKS5, the difference is that the SOCKS4 agent only supports TCP protocol (Transmission Control Protocol), and the SOCKS5 agent supports both the TCP protocol and the UDP protocol (that is, the user Packet protocol), but also supports various authentication mechanisms, Server-side domain name resolution, and so on. SOCK4 can do SOCKS5 can be obtained, but SOCKS5 can do SOCK4 is not necessarily able to do, such as our commonly used chat tool QQ in the use of proxy when using the SOCKS5 agent, because it needs to use the UDP protocol to transfer data

The use of requests library of Geek College

10-wall-through proxy settings

1.5.socket Proxy
See the socket proxy in Python, the lower socket proxy looks like this:
Import socks, Socket
Socks.setdefaultproxy (socks. PROXY_TYPE_SOCKS5, "Proxy_host", Proxy_port)
Socket.socket = Socks.socksocket
Need to socks library.

Python crawler advanced seven set ADSL dial-up Server Proxy

2.urllib2
ImportUrllib2req= Urllib2. Request ('HTTP://HTTPBIN.ORG/IP') Req_https= Urllib2. Request ('HTTPS://HTTPBIN.ORG/IP') Proxy_http= Urllib2. Proxyhandler ({'http':'http://127.0.0.1:1080'}) Proxy_https= Urllib2. Proxyhandler ({'HTTPS':'https://127.0.0.1:1080'}) Opener=Urllib2.build_opener (proxy_http, Proxy_https)#Urllib2.install_opener (opener)PrintUrllib2.urlopen (req). Read ()PrintUrllib2.urlopen (REQ_HTTPS). Read ()PrintOpener.open (req, timeout=10). Read ()PrintOpener.open (Req_https, timeout=10). Read ()

3.requests
ImportRequests#proxies={' http ': ' http://127.0.0.1:1080 ', ' https ': ' http://127.0.0.1:1080 '}proxies={'http':'socks5://127.0.0.1:1080','HTTPS':'socks5://127.0.0.1:1080'}#s.proxies = ProxiesPrintRequests.get ('HTTP://HTTPBIN.ORG/IP'). ContentPrintRequests.get ('HTTPS://HTTPBIN.ORG/IP'). ContentPrintRequests.get ('HTTP://HTTPBIN.ORG/IP', Proxies=proxies, timeout=10). ContentPrintRequests.get ('HTTPS://HTTPBIN.ORG/IP', Proxies=proxies, timeout=10). Content

4. More Bottom Socket.socket
#pip install requests[socks]ImportSocketImportSocksImportRequestsdefault_socket=Socket.socketdefget ():PrintUrllib2.urlopen ('HTTP://HTTPBIN.ORG/IP', timeout=10). Read ()PrintUrllib2.urlopen ('HTTPS://HTTPBIN.ORG/IP', timeout=10). Read ()Print(Requests.get ('HTTP://HTTPBIN.ORG/IP', timeout=10). Text)Print(Requests.get ('HTTPS://HTTPBIN.ORG/IP', timeout=10). Text)Print 'No proxy:'get () socks.set_default_proxy (socks. SOCKS5,'127.0.0.1', 1080) Socket.socket=Socks.socksocketPrint 'Proxy:'get () Socket.socket=Default_socketPrint 'No proxy:'get ()

Python's Generation _ Manager

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.