How to get python gspread to use a SOCKS proxy server for connections?

谁说胖子不能爱 提交于 2019-12-12 02:07:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!