Skip to content

w13b3/playwright-apirequest-builder

Repository files navigation

🎭 Playwright APIRequest builder

Checked with mypy Code style: black Imports: isort PyPI - Wheel PyPI version

Documented

Read it here documentation
Read more about the builder pattern on refactoring.guru

Example

# sync example
from playwright.sync_api import sync_playwright
from playwright_request.sync_builder import RequestBuilder

with sync_playwright() as p:
    builder = RequestBuilder(p, base_url='https://playwright.dev/')
    request = builder.get("python/docs/intro").create_request()
    response = request()
    print(response.text())
# async example
import asyncio
from playwright.async_api import async_playwright
from playwright_request.async_builder import RequestBuilder

async def main():
    async with async_playwright() as p:
        builder = RequestBuilder(p, base_url='https://playwright.dev/')
        request = builder.get("python/docs/intro").create_request()
        response = await request()
        print(await response.text())

asyncio.run(main())

Requirements

Python3
Playwright >= 1.26.0

License

Apache-2.0 license