如何在Dropbox API中使用代理?

时间:2017-01-08 20:54:13

标签: python proxy dropbox-api

dbx = dropbox.dropbox.Dropbox('***************')
f = open("/home/net/a.py", 'rb')
data = f.read()
res = dbx.files_upload(data, "/a.py", dropbox.files.WriteMode.overwrite)

现在,我想使用代理,怎么做?

1 个答案:

答案 0 :(得分:1)

def get_my_proxy():
    """ Static method to get proxy
    """
    proxy = '134.245.32.30:80'
    http_proxy = "http://" + proxy
    https_proxy = "https://" + proxy
    ftp_proxy = "ftp://" + proxy

    proxyDict = {
        "http": http_proxy,
        "https": https_proxy,
        "ftp": ftp_proxy
    }
    return proxyDict

import dropbox
access_token = 'myawesomeaccesstoken'
mysesh = dropbox.create_session(1,get_my_proxy())
dbx = dropbox.Dropbox(access_token,session=mysesh)

# Test the connection
dbx.users_get_current_account()