【问题标题】:How to use Tumblr Api through a proxy in python如何通过 python 中的代理使用 Tumblr Api
【发布时间】:2018-05-19 23:31:04
【问题描述】:

如何通过代理使用 Tumblr api。 任何帮助将不胜感激。

我想使用通过代理进行 api 调用的 Tumblr api。

任何有关如何实现这一目标的帮助将不胜感激。 谢谢。

这是在没有代理的情况下使用 api 的正常方式。它们是我使用代理的一种方式吗?

import pytumblr
client = pytumblr.TumblrRestClient(
    '<consumer_key>',
    '<consumer_secret>',
    '<oauth_token>',
    '<oauth_secret>',
)

client.info() # get information about the authenticating user
client.dashboard() # get the dashboard for the authenticating user
client.likes() # get the likes for the authenticating user
client.following() # get the blogs followed by the authenticating user
# How can I use it with proxy, that's authenticate with proxy.

【问题讨论】:

    标签: python python-3.x rest python-requests pytumblr


    【解决方案1】:

    pytumblr 使用requests 发送HTTP 请求。所以你 can 设置 bash 环境变量 'HTTP_PROXY' 和 'HTTPS_PROXY' 喜欢

    $ export HTTP_PROXY="http://127.0.0.1:1080" # or socks5
    $ export HTTPS_PROXY="http://127.0.0.1:1080"
    $ python3 ./tumblr_code.py
    

    import os
    
    os.environ['HTTP_PROXY'] = 'http://127.0.0.1:1080'
    os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:1080'
    
    // remaining pytumblr codes
    

    【讨论】:

      猜你喜欢
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      • 1970-01-01
      • 1970-01-01
      • 2016-02-26
      • 2021-11-18
      • 1970-01-01
      相关资源
      最近更新 更多