一.代码
复制#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import socket
import socks
SOCKS5_PROXY_HOST = 'xxxx' # socks 代理IP地址
SOCKS5_PROXY_PORT = xxx # socks 代理本地端口
default_socket = socket.socket
socks.set_default_proxy(socks.SOCKS5, SOCKS5_PROXY_HOST, SOCKS5_PROXY_PORT)
socket.socket = socks.socksocket
session = requests.session()
session.keep_alive = False
res=session.get("http://ipconfig.cc/",timeout=5)
print(res.text)