python sock5代理

安装 pysocks:pip install pysocks

# coding:utf-8
'''
@version: python3.6
@author: ‘eric‘
@license: Apache Licence
@contact: steinven@qq.com
@software: PyCharm
@file: pysocks.py
@time: 2020/9/25 16:27
'''
import socket

import requests
import socks

socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9311)
socket.socket = socks.socksocket


def main():
    url = 'https://api.ip.sb/ip'
    html = requests.get(url).text
    print(html)


if __name__ == '__main__':
    main()

原文地址:https://www.cnblogs.com/steinven/p/14838231.html