Python 笔记 requests库使用代理

一个被自己忘记多次,又搜索了多次的方法,笔记

Code:

import requests as r url = "" socks5 = "socks5://127.0.0.1:1080" https_proxy = ":1080" http_proxy = ":1080" proxy_Dict = { "socks5":socks5, "http":http_proxy, "https":https_proxy } rsp = r.get(url=url, proxies=proxy_Dict)

proxies 的语法是{"protocol":"ip:port", ...}.