Python proxy IP code example

Mondo Technology Updated on 2024-03-04

This article is originally published by Siyetian, **Please indicate the source.

Click on the avatar to receive the IP

Tunnels and other IPs also have the advantage that they are easier to configure than routers, and can generate various records in the process of working, and work at the application layer, which can check various data and generate various logs and records according to certain guidelines. In addition, the IP can also filter the data content, flexibly or even fully control the incoming and outgoing traffic and content, and provide users with a transparent encryption mechanism.

For HTTP requests, we generally use the requests library, which supports HTTP https**. The installation is as follows.

pip install requests

If you need to use socks5**, you can install a version that supports socks.

pip install 'requests[socks]'

Let's take the use of socks5** as an example.

import requests

proxyhost = "222.222.222.222"The obtained **IP address

proxyport = "12345"The ** port obtained.

key = "key"User key

passwd = "123456"User password.

Ledger mode.

proxy = 'socks5://{}:'.format(key, passwd, proxyhost, proxyport)

If you use the IP address whitelist mode, replace the previous row with the downlink.

# proxy = 'socks5://{}:'.format(proxyhost, proxyport)

proxies =

response = requests.get("", proxies=proxies)

print(response.text)

If you want to use HTTP https, modify the access protocol as follows.

Ledger mode.

proxy = 'http://{}:'.format(key, passwd, proxyhost, proxyport)

If you use the IP address whitelist mode, replace the previous row with the downlink.

# proxy = 'http://{}:'.format(proxyhost, proxyport)

Related Pages