kwork-api/Untitled.ipynb

151 lines
9.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "f28552f1-618c-4853-92e2-566554a2de2c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import asyncio\n",
"import logging\n",
"from kwork_api import KworkClient\n",
"from dotenv import load_dotenv\n",
"import os\n",
"\n",
"logging.basicConfig(level=logging.DEBUG) # или INFO для меньшего шума\n",
"\n",
"load_dotenv('tests/e2e/.env')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "953d142e-a575-41b7-927d-8cd1546d2747",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:kwork_api.client:Login request: POST https://api.kwork.ru/signIn (user: JTJagOmega)\n",
"DEBUG:kwork_api.client:Login payload: {'login': 'JTJagOmega', 'password': '8AQhyzQRcTJ6v81maCNa', 'uad': '', 'device': ''}\n",
"DEBUG:httpcore.connection:connect_tcp.started host='api.kwork.ru' port=443 local_address=None timeout=30.0 socket_options=None\n",
"DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x75bea599dd00>\n",
"DEBUG:httpcore.connection:start_tls.started ssl_context=<ssl.SSLContext object at 0x75bea597e0d0> server_hostname='api.kwork.ru' timeout=30.0\n",
"DEBUG:httpcore.connection:start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x75bec0323a10>\n",
"DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:send_request_headers.complete\n",
"DEBUG:httpcore.http11:send_request_body.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:send_request_body.complete\n",
"DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Server', b'QRATOR'), (b'Date', b'Sun, 29 Mar 2026 23:32:52 GMT'), (b'Content-Type', b'application/json; charset=utf-8'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'Keep-Alive', b'timeout=15'), (b'Vary', b'Accept-Encoding, User-Agent'), (b'Content-Security-Policy', b\"frame-ancestors 'self' https://webvisor.com https://awards.ratingruneta.ru\"), (b'Set-Cookie', b'RORSSQIHEK=a4fe3ce9aadf6c71d101f2914ddc4594; expires=Wed, 01-Apr-2026 23:32:52 GMT; Max-Age=259200; path=/; secure; HttpOnly; SameSite=None'), (b'Expires', b'Thu, 19 Nov 1981 08:52:00 GMT'), (b'Cache-Control', b'no-store, no-cache, must-revalidate'), (b'Pragma', b'no-cache'), (b'Set-Cookie', b'csrf_user_token=fd9c64e5301c952c692d6b60e0693d05; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None'), (b'Set-Cookie', b'userId=18845973; expires=Wed, 26-Mar-2036 23:32:52 GMT; Max-Age=315360000; path=/; secure; SameSite=None'), (b'Set-Cookie', b'slrememberme=18845973_%242y%2410%24tbgXEdroo8Dg3L6TjfGfDe6tmbPkwd1.aU4lMgEODFpxNTqKlr3v6; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None'), (b'Strict-Transport-Security', b'max-age=15552000'), (b'X-Frame-Options', b'DENY'), (b'X-Content-Type-Options', b'nosniff'), (b'Content-Encoding', b'gzip')])\n",
"INFO:httpx:HTTP Request: POST https://api.kwork.ru/signIn \"HTTP/1.1 200 OK\"\n",
"DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:receive_response_body.complete\n",
"DEBUG:httpcore.http11:response_closed.started\n",
"DEBUG:httpcore.http11:response_closed.complete\n",
"DEBUG:kwork_api.client:Login response status: 200\n",
"DEBUG:kwork_api.client:Login response headers: {'server': 'QRATOR', 'date': 'Sun, 29 Mar 2026 23:32:52 GMT', 'content-type': 'application/json; charset=utf-8', 'transfer-encoding': 'chunked', 'connection': 'keep-alive', 'keep-alive': 'timeout=15', 'vary': 'Accept-Encoding, User-Agent', 'content-security-policy': \"frame-ancestors 'self' https://webvisor.com https://awards.ratingruneta.ru\", 'set-cookie': 'RORSSQIHEK=a4fe3ce9aadf6c71d101f2914ddc4594; expires=Wed, 01-Apr-2026 23:32:52 GMT; Max-Age=259200; path=/; secure; HttpOnly; SameSite=None, csrf_user_token=fd9c64e5301c952c692d6b60e0693d05; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None, userId=18845973; expires=Wed, 26-Mar-2036 23:32:52 GMT; Max-Age=315360000; path=/; secure; SameSite=None, slrememberme=18845973_%242y%2410%24tbgXEdroo8Dg3L6TjfGfDe6tmbPkwd1.aU4lMgEODFpxNTqKlr3v6; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'cache-control': 'no-store, no-cache, must-revalidate', 'pragma': 'no-cache', 'strict-transport-security': 'max-age=15552000', 'x-frame-options': 'DENY', 'x-content-type-options': 'nosniff', 'content-encoding': 'gzip'}\n",
"INFO:kwork_api.client:Login successful: user_id=18845973, csrf_token=N/A\n",
"DEBUG:kwork_api.client:Login response data: {'success': True, 'response': {'token': '48e75666c8b5c3ffa97f5ae4bfa6ecfa', 'expired': 31536000, 'need_2fa': False}}\n",
"DEBUG:kwork_api.client:Login cookies: ['RORSSQIHEK', 'csrf_user_token', 'userId', 'slrememberme']\n",
"DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:send_request_headers.complete\n",
"DEBUG:httpcore.http11:send_request_body.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:send_request_body.complete\n",
"DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Server', b'QRATOR'), (b'Date', b'Sun, 29 Mar 2026 23:32:52 GMT'), (b'Content-Type', b'application/json; charset=utf-8'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'Keep-Alive', b'timeout=15'), (b'Vary', b'Accept-Encoding, User-Agent'), (b'Content-Security-Policy', b\"frame-ancestors 'self' https://webvisor.com https://awards.ratingruneta.ru\"), (b'Expires', b'Thu, 19 Nov 1981 08:52:00 GMT'), (b'Cache-Control', b'no-store, no-cache, must-revalidate'), (b'Pragma', b'no-cache'), (b'Set-Cookie', b'slrememberme=18845973_%242y%2410%24Kn3Qr%2FBaJ24e5CWBpUvbBuMP38SflcAdTUtmlW1XXVEJFDVbOmO96; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None'), (b'Set-Cookie', b'uad=1884597369c9b6a47efb8415191577; expires=Mon, 29-Mar-2027 23:32:52 GMT; Max-Age=31536000; path=/; secure; HttpOnly; SameSite=None'), (b'Set-Cookie', b'mobile_token=48e75666c8b5c3ffa97f5ae4bfa6ecfa; expires=Sun, 29-Mar-2026 23:33:52 GMT; Max-Age=60; path=/; secure; HttpOnly; SameSite=None'), (b'Strict-Transport-Security', b'max-age=15552000'), (b'X-Frame-Options', b'DENY'), (b'X-Content-Type-Options', b'nosniff'), (b'Content-Encoding', b'gzip')])\n",
"INFO:httpx:HTTP Request: POST https://api.kwork.ru/getWebAuthToken \"HTTP/1.1 200 OK\"\n",
"DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'POST']>\n",
"DEBUG:httpcore.http11:receive_response_body.complete\n",
"DEBUG:httpcore.http11:response_closed.started\n",
"DEBUG:httpcore.http11:response_closed.complete\n",
"INFO:kwork_api.client:Got web_auth_token: DKZL5BjWmWo75GQmmCus...\n",
"DEBUG:httpcore.connection:close.started\n",
"DEBUG:httpcore.connection:close.complete\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Logged in as: DKZL5BjWmWo75GQmmCus...\n"
]
}
],
"source": [
"try:\n",
" client = await KworkClient.login(\n",
" username=os.getenv('KWORK_USERNAME'),\n",
" password=os.getenv('KWORK_PASSWORD')\n",
" )\n",
" print(f\"✅ Logged in as: {client.token[:20]}...\")\n",
"except Exception as e:\n",
" print(e)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "655aa71e-5645-4c7a-aadd-5b044a0713c9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'DKZL5BjWmWo75GQmmCusW48U3K1ZL9YUWVGs4oGnvVX5xYPYVrdzP1L6b0ko'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client.token"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f9a5161a-4051-4321-849b-c3b416a939a0",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}