https://github.com/w13b3/playwright-apirequest-builder
:performing_arts: Playwright APIRequest builder
https://github.com/w13b3/playwright-apirequest-builder
builder builder-pattern playwright playwright-api playwright-python web-request
Last synced: 6 months ago
JSON representation
:performing_arts: Playwright APIRequest builder
- Host: GitHub
- URL: https://github.com/w13b3/playwright-apirequest-builder
- Owner: w13b3
- License: apache-2.0
- Created: 2023-01-28T19:38:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-29T10:42:30.000Z (almost 3 years ago)
- Last Synced: 2024-04-26T13:41:10.547Z (over 1 year ago)
- Topics: builder, builder-pattern, playwright, playwright-api, playwright-python, web-request
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
🎠[Playwright] [APIRequest] builder
===
[](https://mypy-lang.org/)
[](https://github.com/psf/black)
[](https://pycqa.github.io/isort/)
[](https://pypi.org/project/playwright-apirequest-builder/)
[](https://badge.fury.io/py/playwright-apirequest-builder)
Documented
---
Read it here [documentation](./doc)
Read more about the _builder pattern_ on [refactoring.guru](https://refactoring.guru/design-patterns/builder/python/example#lang-features)
Example
---
```python
# 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())
```
```python
# 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](LICENSE)
[Playwright]: https://playwright.dev/python/
[APIRequest]: https://playwright.dev/python/docs/api/class-apirequest