Skip to main content

llama-index tools playwright integration

Project description

Playwright Browser Tool

This tool is a wrapper around the Playwright library. It allows you to navigate to a website, extract text and hyperlinks, and click on elements.

Warning Only support async functions and playwright browser APIs.

Installation

pip install llama-index-tools-playwright

Setup

In order to use this tool, you need to have a async Playwright browser instance. You can hook one up by running the following code:

browser = PlaywrightToolSpec.create_async_playwright_browser(headless=False)
playwright_tool = PlaywrightToolSpec.from_async_browser(browser)

Usage

Navigate to a website

await playwright_tool.navigate_to("https://playwright.dev/python/docs/intro")

Navigate back

await playwright_tool.navigate_back()

Get current page URL

await playwright_tool.get_current_page()

Extract all hyperlinks

await playwright_tool.extract_hyperlinks()

Extract all text

await playwright_tool.extract_text()

Get element attributes

element = await playwright_tool.get_elements(
    selector="ELEMENT_SELECTOR", attributes=["innerText"]
)

Click on an element

await playwright_tool.click(selector="ELEMENT_SELECTOR")

Fill in an input field

await playwright_tool.fill(selector="ELEMENT_SELECTOR", value="Hello")

Agentic Usage

This tool has a more extensive example usage documented in a Jupyter notebook here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_playwright-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_playwright-0.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_playwright-0.2.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_playwright-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for llama_index_tools_playwright-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a5ff32cbbb102ade28d0790f71ccc516ecd4e8520e934b0274dc2cdf613d7a24
MD5 500390d57a668be0aa7da4904220486f
BLAKE2b-256 5b659f20e7ac7b7c3a2a0fe87f9ef29f25321bca4657325cad3c856b292ad5ab

See more details on using hashes here.

File details

Details for the file llama_index_tools_playwright-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_playwright-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01221b541f83db5ddc9a9e1b388682ac13dffe3a0a18ba1b6c82388d35584c85
MD5 36641d3e8424058ffdd2e4897199f2fc
BLAKE2b-256 4452b8c1f242c6dc9e01c03630dcafbc0715965ea6be66a33504dc0fa3d1cbea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page