Skip to content

cannot use playwright-python in fastapi, got NotImplementedError #8391

Answered by iudeen
phoenixor asked this question in Questions
Discussion options

You must be logged in to vote

It works fine. I am not able to find any issues. Below is the code I used.

import fastapi
from playwright.async_api import async_playwright

class FS131VIAPI:
    def __init__(self):
        self.cookie = None
    async def fetch(self, params):
        await self.login_for_cookie()

    async def login_for_cookie(self):
        async with async_playwright() as p:
            browser = await p.chromium.launch(headless=False)
            context = await browser.new_context()
            page = await context.new_page()
            await page.goto("https://cn.bing.com/")
            print(await page.title())
            print(await context.cookies())
            self.cookie = await context.co…

Replies: 8 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jvhuaiying
Comment options

Comment options

You must be logged in to vote
2 replies
@kaonick
Comment options

@jvhuaiying
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants
Converted from issue

This discussion was converted from issue #5446 on February 28, 2023 15:42.