{"id":16393557,"url":"https://github.com/code-yeongyu/playwright-page-pool","last_synced_at":"2025-03-27T07:12:16.869Z","repository":{"id":246323534,"uuid":"806100656","full_name":"code-yeongyu/playwright-page-pool","owner":"code-yeongyu","description":"Handle multiple playwright pages concurrently with ease and speed. ","archived":false,"fork":false,"pushed_at":"2024-05-27T11:54:19.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T07:04:30.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-yeongyu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-26T11:30:49.000Z","updated_at":"2024-05-27T11:54:23.000Z","dependencies_parsed_at":"2024-06-27T06:56:21.329Z","dependency_job_id":null,"html_url":"https://github.com/code-yeongyu/playwright-page-pool","commit_stats":null,"previous_names":["code-yeongyu/playwright-page-pool"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fplaywright-page-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fplaywright-page-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fplaywright-page-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fplaywright-page-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-yeongyu","download_url":"https://codeload.github.com/code-yeongyu/playwright-page-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798359,"owners_count":20673902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:53:36.243Z","updated_at":"2025-03-27T07:12:16.844Z","avatar_url":"https://github.com/code-yeongyu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Playwright Page Pool 🎭🏊‍♀️\n\n[![PyPI version](https://badge.fury.io/py/playwright-page-pool.svg)](https://badge.fury.io/py/playwright-page-pool)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nWelcome to Playwright Page Pool! 🎉\n\nThis Python module provides a convenient way to manage a pool of Playwright browser pages within a given browser context.\nBy leveraging Python's async capabilities, **you can handle multiple pages concurrently with ease and speed**, ensuring your tasks are executed swiftly and efficiently. 🚀\nIt allows you to efficiently reuse pages or create new pages on demand, making your web automation tasks a breeze! ✨\n\n## Features 🌟\n\n- **🌐 The best tool for working across multiple pages**\n- 🏊‍♀️ Manages a pool of Playwright browser pages\n- 🔄 Supports reuse of pages for improved performance\n- 🆕 Creates new pages on demand when needed\n- 🚀 Utilizes asynchronous operations for efficient execution\n- 🔒 Ensures thread safety with semaphores and events\n- 🎨 Customizable page initialization with `page_initiator` callback\n- 🎯 Automatic closing of pages when the pool is no longer needed\n\n## Installation 🔧\n\nTo start using Playwright Page Pool, simply install it via pip:\n\n```sh\npip install playwright-page-pool\n```\n\nMake sure you have Playwright installed and set up in your project as well.\n\n## Usage 📝\n\nHere's a quick example of how to use Playwright Page Pool in your code:\n\n```python\nimport asyncio\n\nfrom playwright.async_api import async_playwright\nfrom playwright_page_pool import PagePool\n\nasync def run_example(pool: PagePool) -\u003e None:\n    async with pool.acquire() as page:\n        await page.goto(\"https://example.com\")\n        print(await page.title())\n\nasync def main(*args, **kwargs) -\u003e None:\n    async with async_playwright() as p:\n        browser = await p.chromium.launch()\n        context = await browser.new_context()\n\n        async with PagePool(context=context, reuse_pages=True) as pool:\n            run_examples = [run_example(pool) for _ in range(10)]\n            await asyncio.gather(*run_examples)  # 10 tasks are executed concurrently\n\n        await browser.close()\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n```\n\nIn this example, we create a PagePool instance with a Playwright browser context. We set reuse_pages=True to enable page reuse for improved performance. We then define a run_example function that acquires a page from the pool using the acquire context manager, navigates to a URL, and prints the page title.\nFinally, we create 10 tasks using run_example and execute them concurrently using asyncio.gather. The PagePool manages the allocation and reuse of pages efficiently.\n\n## Configuration 🛠️\n\nWhen creating a PagePool instance, you can customize its behavior with the following parameters:\n\n- context: The Playwright browser context associated with the page pool.\n- max_pages: The maximum number of pages that can be opened at once. Defaults to the number of CPU cores.\n- page_initiator: An optional asynchronous callable that is called each time a new page is created. This allows you to perform custom initialization on each page.\n- reuse_pages: Determines whether pages should be reused. If False, a new page is created for each acquisition. Defaults to False. When set to True, it eliminates the overhead of opening and closing pages repeatedly, thereby improving performance.\n\n## Contributing 🤝\n\nContributions to Playwright Page Pool are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.\n\n## License 📄\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fplaywright-page-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-yeongyu%2Fplaywright-page-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fplaywright-page-pool/lists"}