DedInc / pyanty

Python module for controlling Dolphin browser profiles using Selenium, Pyppeteer, and Playwright. Includes Dolphin API for profile management.
https://pypi.org/project/pyanty
MIT License
45 stars 14 forks source link

add import cookie #8

Closed FreeM1ne closed 8 months ago

FreeM1ne commented 8 months ago

add import cookie

DedInc commented 8 months ago

Later I may globally update many things from Dolphin in the API, but for now it can be done like this:

async def main():
    browser = await dolphin.get_browser(ws_endpoint, port)
    pages = await browser.pages()
    page = pages[0]

    with open(cookie_file, 'r') as f:
        cookies = json.load(f)

    for cookie in cookies:
        await page.setCookie({'name': cookie['name'], 'value': cookie['value'], 'domain': cookie['domain']})

    await page.goto('http://google.com/')
    await asyncio.sleep(5)
    await browser.disconnect()