Windows 10 Python 3.11
In the example code
import asyncio
from shardx import ShardX
async def main():
sdk = ShardX()
# Engine + Widevine + fingerprint library auto-download from CDN on
# the first `session`/`launch`/`list_profiles` call (~170 MB once,
# etag-cached afterward). No separate install step.
# Create a persistent profile from a library template (or create_profile()
# for a random one). Library templates aren't launched directly — this
# freezes an enriched copy under a unique id you can return to. Do it once.
profile = sdk.create_profile("win-rtx4060")
# Launch + drive in one call. Yields a patchright `Browser`.
async with sdk.session(profile, proxy="socks5://user:pass@host:port") as browser:
ctx = browser.contexts[0]
page = await ctx.new_page()
await page.goto("https://browserleaks.com/quic")
print(await page.title())
# Inspect what the SDK resolved before launch:
sess = browser._shardx
print(sess.geo) # GeoInfo(...) from ip-api / ipapi.co
print(sess.proxy_udp_ms, # UDP RTT in ms or None
sess.quic_enabled, # bool
sess.webrtc_mode) # "auto" | "tcp_only" | "block"
# browser + udd shut down cleanly on exit
asyncio.run(main())
I get error
Traceback (most recent call last): File "D:\PycharmProjects\test_ShardBrowser\main.py", line 30, in <module> asyncio.run(main()) File "d:\Python\3.11.9\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "d:\Python\3.11.9\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\Python\3.11.9\Lib\asyncio\base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "D:\PycharmProjects\test_ShardBrowser\main.py", line 13, in main profile = sdk.create_profile("win-rtx4060") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PycharmProjects\test_ShardBrowser\.venv\Lib\site-packages\shardx\__init__.py", line 115, in create_profile config = dict(self.library.load(template).config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PycharmProjects\test_ShardBrowser\.venv\Lib\site-packages\shardx\profile.py", line 119, in load return Profile.from_file(path) ^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PycharmProjects\test_ShardBrowser\.venv\Lib\site-packages\shardx\profile.py", line 29, in from_file cfg = json.loads(p.read_text()) ^^^^^^^^^^^^^ File "d:\Python\3.11.9\Lib\pathlib.py", line 1059, in read_text return f.read() ^^^^^^^^ File "d:\Python\3.11.9\Lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 6843: character maps to <undefined>
I suggests solving this problem by replacing in .venv\Lib\site-packages\shardx\profile.py line
cfg = json.loads(p.read_text())
to
cfg = json.loads(p.read_text(encoding="utf-8"))
Windows 10 Python 3.11
In the example code
I get error
I suggests solving this problem by replacing in .venv\Lib\site-packages\shardx\profile.py line
cfg = json.loads(p.read_text())to
cfg = json.loads(p.read_text(encoding="utf-8"))