如何在不使用环境变量的情况下将代理添加到 Praw?

How can proxies be added to Praw without using environment variables?

我正在尝试为 Python 使用 Praw 模块时测试代理,并找到了一些关于设置环境变量的信息。我正在尝试确定是否有直接的方法将代理用作 Reddit() 初始值设定项的附加关键字?

我试着到处寻找有关这方面的更多信息,并认为将代理与 Praw 一起使用会得到更广泛的记录。

如果你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://localhost:3128'
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')