File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ :performing_arts : [ Playwright] [ APIRequest] builder
2+ ===
3+
4+ [ ![ Checked with mypy] ( https://www.mypy-lang.org/static/mypy_badge.svg )] ( https://mypy-lang.org/ )
5+ [ ![ Code style: black] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
6+ [ ![ Imports: isort] ( https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336 )] ( https://pycqa.github.io/isort/ )
7+
8+
9+ Documented
10+ ---
11+ Read it here [ :link : documentation] ( ./doc )
12+ Read more about the _ builder pattern_ on [ :link : refactoring.guru] ( https://refactoring.guru/design-patterns/builder/python/example#lang-features )
13+
14+
15+ Example
16+ ---
17+
18+ ``` python
19+ # sync example
20+ from playwright.sync_api import sync_playwright
21+ from playwright_request.sync_builder import RequestBuilder
22+
23+ with sync_playwright() as p:
24+ builder = RequestBuilder(p, base_url = ' https://playwright.dev/' )
25+ request = builder.get(" python/docs/intro" ).create_request()
26+ response = request()
27+ print (response.text())
28+ ```
29+
30+ ``` python
31+ # async example
32+ import asyncio
33+ from playwright.async_api import async_playwright
34+ from playwright_request.async_builder import RequestBuilder
35+
36+ async def main ():
37+ async with async_playwright() as p:
38+ builder = RequestBuilder(p, base_url = ' https://playwright.dev/' )
39+ request = builder.get(" python/docs/intro" ).create_request()
40+ response = await request()
41+ print (await response.text())
42+
43+ asyncio.run(main())
44+ ```
45+
46+
47+ Requirements
48+ ---
49+ Python3
50+ Playwright >= 1.26.0
51+
52+
53+ [ Playwright ] : https://playwright.dev/python/
54+ [ APIRequest ] : https://playwright.dev/python/docs/api/class-apirequest
55+ [ `max_redirects` ] : https://playwright.dev/python/docs/api/class-apirequestcontext#api-request-context-delete-option-max-redirects
You can’t perform that action at this time.
0 commit comments