🎭 Playwright APIRequest builder
Read it here documentation
Read more about the builder pattern on refactoring.guru
# 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())
Python3
Playwright >= 1.26.0