cannot use playwright-python in fastapi, got NotImplementedError
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
// api.py
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()
logger.info(params)
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.cookies()
await context.close()
// main.py
...
from api import FS131VIAPI
fs131vi_api = FS131VIAPI()
@app.post("/")
async def index():
await fs131vi_api.fetch({"SERVICE_IDS": "xxx"})
Description
open the browser and call the endpoint ‘/’ fastapi received the request and call playwright-python to call “https://cn.bing.com/”, return cookies
Operating System
Windows
Operating System Details
windows 10
FastAPI Version
0.85.0
Python Version
3.10.2
Additional Context
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
python - Running an Asyncio Subprocess in FastApi results in ...
I've read similar questions on the issue: Why am I getting NotImplementedError with async and await on Windows? Asyncio.create_subprocess_exec ...
Read more >as a beginner , mine is pyinputplus : r/Python - Reddit
I barely find my self writing a class that is not attrs and usually if i do, i change my mind after 20...
Read more >Use get_column_sets in dbt-osmosis With Examples | LambdaTest
Learn how to use get_column_sets function in dbt-osmosis framework for your next python automation project with LambdaTest Automation Testing Advisor.
Read more >[Example code]-Google scrape returns no description or email
I'm trying to get a description and email from each of Google searches, but it returns only titles and links. I'm using Selenium...
Read more >how to install express in console Code Example
What is Node.js, Express.js? ... is npm express? ... Which command is correct to install the express package using Node Package Manager? ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
problem can be solved by setting reload=False. more can be found on https://github.com/microsoft/playwright-python/issues/1099
i am talking about playwright-python work with reload when developing