Give PRAW 8.0.3 a SOCKS-aware Requests session through requestor_kwargs:

import praw
import requests

session = requests.Session()
session.proxies.update({
    'http': 'socks5h://proxy.example:1080',
    'https': 'socks5h://proxy.example:1080',
})
reddit = praw.Reddit(
    client_id=client_id,
    client_secret=client_secret,
    user_agent=user_agent,
    requestor_kwargs={'session': session},
)

Use the application’s Reddit credentials and user agent, then make API calls through this reddit instance. Manage its requestor and session through the application’s normal cleanup.

Requests requires its SOCKS support. socks5h delegates destination-name resolution to the proxy; socks5 resolves locally.

A public endpoint from the SOCKS5 proxy list can supply the address in this map. Create Session() first and update its proxies attribute as shown. Its constructor has no proxies keyword.

The supplied session retains Requests’ environment integration, so inherited proxy and bypass settings can affect route selection. For a fully application-owned route, review trust_env. Disabling it also requires supplying any trust and authentication inputs that previously came from that environment.

Tënë sô zo