Configure Proxy priority and usage
mainProxies can be applied at different levels. The priority order is:
api.proxy(highest)TWS_PROXYenvironment variable- Account-specific proxy (lowest)
Python API usage:
Set a proxy for the entire API instance:
api = API(proxy="http://login:pass@example.com:8080")Set a proxy for a specific account:
await api.pool.add_account(
"user1",
"pass1",
"user1@example.com",
"email_pass1",
proxy="http://login:pass@example.com:8080",
)CLI usage:
TWS_PROXY=socks5://user:pass@127.0.0.1:1080 twscrape user_by_login xdevelopersawait api.pool.add_account(
"user1",
"pass1",
"user1@example.com",
"email_pass1",
proxy="http://login:pass@example.com:8080",
)
api = API(proxy="http://login:pass@example.com:8080")
doc = await api.user_by_login("xdevelopers")