问题
How could I get my script that's using gspread to have the gspread connections to google's servers use a SOCKS proxy?
回答1:
SocksiPy should work for this, as per the SO question: How can I use a SOCKS 4/5 proxy with urllib2?.
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 8080)
socket.socket = socks.socksocket
import gspread
# do whatever
If this is not the desired result, you may have to create a custom instance of the bundled HTTPSession object.
来源:https://stackoverflow.com/questions/29710776/how-to-get-python-gspread-to-use-a-socks-proxy-server-for-connections