Drunk Codes
Drunk Codes

Reputation: 39

How to use Tumblr Api through a proxy in python

How can I use the Tumblr api through a proxy. Any help will be appreciated.

I want to use the Tumblr api that's make api calls through a proxy .

Any help on how to achieve that would be highly appreciated . Thanks.

This is the normal way of using the api without proxy. Is they a way for me to use it with proxy.

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.

Upvotes: 0

Views: 126

Answers (1)

jasonz
jasonz

Reputation: 1345

pytumblr use requests to send HTTP requests. So you can set bash environment variables 'HTTP_PROXY' and 'HTTPS_PROXY' like

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

or

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

Upvotes: 1

Related Questions