Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit cfb51dc

Browse files
committed
dhwahdwa
1 parent 8b94098 commit cfb51dc

4 files changed

Lines changed: 64 additions & 2 deletions

File tree

client_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async def websocket_client(url, pro):
1414
async with websockets.connect(
1515
url,
1616
extra_headers={
17-
"Origin": "https://pocket-link19.co",
18-
# "Origin": "https://po.trade/"
17+
#"Origin": "https://pocket-link19.co",
18+
"Origin": "https://po.trade/"
1919
},
2020
) as websocket:
2121
async for message in websocket:
-11 Bytes
Binary file not shown.
1.96 KB
Binary file not shown.

test/client_test_1.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import websockets
2+
import anyio
3+
from rich.pretty import pprint as print
4+
import json
5+
6+
SESSION = r'42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"c53eec05c6f8a8be2d134d4fd55266f8\";s:10:\"ip_address\";s:14:\"46.138.176.190\";s:10:\"user_agent\";s:101:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36\";s:13:\"last_activity\";i:1707850603;}9f383935faff5a86bc1658bbde8c61e7","isDemo":1,"uid":72038016,"platform":3}]'
7+
8+
9+
async def websocket_client(url, pro):
10+
while True:
11+
try:
12+
async with websockets.connect(
13+
url,
14+
extra_headers={
15+
"Origin": "https://pocket-link19.co",
16+
#"Origin": "https://po.trade/"
17+
},
18+
) as websocket:
19+
async for message in websocket:
20+
await pro(message, websocket, url)
21+
except KeyboardInterrupt:
22+
exit()
23+
except Exception as e:
24+
print(e)
25+
print("Connection lost... reconnecting")
26+
await anyio.sleep(5)
27+
return True
28+
29+
30+
async def pro(message, websocket, url):
31+
# if byte data
32+
if type(message) == type(b""):
33+
# cut 100 first symbols of byte date to prevent spam
34+
print(str(message)[:100])
35+
return
36+
else:
37+
print(message)
38+
39+
# Code to make order
40+
# data = r'42["openOrder",{"asset":"#AXP_otc","amount":1,"action":"call","isDemo":1,"requestId":14680035,"optionType":100,"time":20}]'
41+
# await websocket.send(data)
42+
43+
if message.startswith('0{"sid":"'):
44+
print(f"{url.split('/')[2]} got 0 sid send 40 ")
45+
await websocket.send("40")
46+
elif message == "2":
47+
# ping-pong thing
48+
print(f"{url.split('/')[2]} got 2 send 3")
49+
await websocket.send("3")
50+
51+
if message.startswith('40{"sid":"'):
52+
print(f"{url.split('/')[2]} got 40 sid send session")
53+
await websocket.send(SESSION)
54+
55+
56+
async def main():
57+
url = "wss://api-l.po.market/socket.io/?EIO=4&transport=websocket"
58+
await websocket_client(url, pro)
59+
60+
61+
if __name__ == "__main__":
62+
anyio.run(main)

0 commit comments

Comments
 (0)