无法弄清楚如何使用Soundcloud API测试代理

时间:2014-09-07 03:17:46

标签: proxy soundcloud python-requests

我正在尝试将我的代理与Soundcloud API一起使用。格式为

client = soundcloud.Client(client_id=client_id,
                           client_secret=client_secret,
                           username=username,
                           password=password,
                           proxies=proxies)

但是,当我将某些内容传递给代理变量时,如

proxies = {'http': 'notavalidip'}

客户端仍然可以登录并正常运行。为什么会发生这种情况?当我通过实际有效代理时,如何测试它实际上会被使用?我相信这个API使用Python请求库,如果这有帮助的话。

1 个答案:

答案 0 :(得分:3)

所有这些选项都传到make_request,最终传递到kwargs内的request_funchttps确实得到requests库的支持。

您的代理只是因为它有错误的方案而通过。与Soundcloud的所有连接都是通过https进行的,而不是http by default。这意味着您没有代理设置,因为您的代理字典没有None密钥。

请参阅here如何将代理设置为proxies,因为字典没有所需的方案。

https变量修改为http而不是ProxyError('Cannot connect to proxy.')后,我抛出了异常({{1}},因此没有静默失败。

希望这是有道理的。