SOCKS5 & more proxy providers for web3py.
Project description
Usage:
from __future__ import annotations
import asyncio
import sys
from os import environ as os_env
from python_socks import ProxyType
from web3 import AsyncWeb3
from web3_proxy import AdvAsyncHTTPProvider
async def main() -> None:
# NOTE: You can parse using func from `aiohttp_socks` lib
addr = os_env['PADDR']
logpass = os_env['PLOGPASS']
phost, pport = addr.split(':')
puser, ppasswd = logpass.split(':')
print('Connecting to:', phost, pport, puser, ppasswd)
provider = AdvAsyncHTTPProvider(
endpoint_uri='https://eth.drpc.org',
proxy_conn_kwargs={
# 'proxy_type': ProxyType.HTTP,
'proxy_type': ProxyType.SOCKS5,
'host': phost,
'port': pport,
'username': puser,
'password': ppasswd,
},
)
w3 = AsyncWeb3(provider)
block_number = await w3.eth.get_block_number()
print(f'Block number is {block_number}')
# NOTE: You can have warning of unclosed session after execution end
# due internal proxy connector..
if __name__ == '__main__':
async_loop = asyncio.get_event_loop()
async_loop.run_until_complete(main())
print('Complete!')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
web3_proxy-0.0.1.tar.gz
(11.6 kB
view details)
Built Distribution
File details
Details for the file web3_proxy-0.0.1.tar.gz
.
File metadata
- Download URL: web3_proxy-0.0.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 PyPy/7.3.10 Linux/6.9.9-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec323c3593d45bc2b3fb0fce71cecdd5a915517e8bf711e72d446ff2e5189525 |
|
MD5 | 086996ef364057f883efa91a6ec675b5 |
|
BLAKE2b-256 | c62be09260432a75d8d79d544d2e95b267044a765751e62af0f499ca775c09a2 |
File details
Details for the file web3_proxy-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: web3_proxy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 PyPy/7.3.10 Linux/6.9.9-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 593e0049eb67306b9b410701e2f5540577ee711a1fdff04eb100d03706c00605 |
|
MD5 | d2e71b12d3054cf526a89bdcfc17c552 |
|
BLAKE2b-256 | 2c20ec833b716b7747923125eddbf4a8cc76c93aab6a5d9453089e7b63e1ff60 |