question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specifying a proxy programatically

See original GitHub issue

Is there any way you could support specifying a proxy programatically, like so:

r = praw.Reddit('Example bot', proxy='http://0.0.0.0/')
r.login()

I would much rather have this than having to deal with config files, and I’m sure others feel the same. If not, would it be pulled if I did this myself?

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
jarhill0commented, Jan 20, 2019

If you configure a custom Session, you can accomplish this without environment variables. You need to modify Session.proxies.

import praw
from requests import Session

session = Session()
session.proxies['https'] = 'https://0.0.0.0'
reddit = praw.Reddit(client_id='SI8pN3DSbt0zor',
                     client_secret='xaxkj7HNh8kwg8e5t4m6KvSrbTI',
                     password='1guiwevlfo00esyy',
                     requestor_kwargs={'session': session},  # pass Session
                     user_agent='testscript by /u/fakebot3',
                     username='fakebot3')

I’m deleting my other two comments because I don’t think they’re helpful.

1reaction
jarhill0commented, Jan 22, 2019

Is there any means of checking the ip connecting to Reddit via Praw?

I don’t believe so, but @bboe can probably correct me if I’m wrong.

Are there any methods from the Reddit entity which return the current proxy after using Session() as shown above

It’s not very elegant, but:

print(reddit._core._requestor._http.proxies)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatically change Windows system proxy settings issue
The solution is to use 'http' as schema in proxy address. Windows set the proxy setting for all protocols if the address schema...
Read more >
Set HTTP proxy in Windows programmatically - Stack Overflow
I'm trying to see if it is possible to set HTTP proxy configuration programmatically from my C++/WinRT code. I found that one can...
Read more >
How to set proxy programatically - Katalon Studio
Until there is an exception list, I'm thinking of setting the proxy when Katalon starts in order to load the plugins, and then...
Read more >
How to change proxy settings programmatically?
I'm using version 10.2 on Linux, and need to access some web services via proxy server sometimes. Is there a way to change...
Read more >
Connecting through Proxy Servers in Core Java - Baeldung
Java provides proxy handlers for HTTP, HTTPS, FTP, and SOCKS protocols. A proxy can be defined for each handler as a hostname and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found