| Total Complexity | 2 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import asyncio |
||
| 2 | from univk_audio import AsyncVKAuth |
||
| 3 | |||
| 4 | # Example with 'async with' construction, that closes session automatically |
||
| 5 | |||
| 6 | async def get_auth_cookies_with_example(): |
||
| 7 | login: str = "79998887776" |
||
| 8 | password: str = "password" |
||
| 9 | |||
| 10 | # user_agent is optional: |
||
| 11 | user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
||
| 12 | |||
| 13 | async with AsyncVKAuth(login = login, password = password, user_agent = user_agent) as auth: |
||
| 14 | |||
| 15 | # .get_auth_cookies Returns a string with cookies |
||
| 16 | # path is optional, if specified - saves cookies in file |
||
| 17 | |||
| 18 | cookies = await auth.get_auth_cookies(path = "cookies.txt") |
||
| 19 | |||
| 20 | print(cookies) |
||
| 21 | |||
| 22 | asyncio.run(get_auth_cookies_with_example()) |
||
| 23 |