Skip to main content

A brief description of what your package does

Project description

pyvigate

Pyvigate: A Python framework that combines headless browsing with LLMs that assists you in your data solutions, product tours, building RAG applications, web automation, functional testing, and many more!

PyPI Downloads

Installation

Pyvigate can be installed using pip or directly from the source for the latest version.

Using pip

pip install pyvigate

Installing from source

git clone https://github.com/kindsmiles/pyvigate.git
cd pyvigate
pip install .

Components

Pyvigate consists of several key components designed to work together seamlessly for web automation tasks.

PlayWrightEngine:

PlayWright is one library we use for headless browsing and other browser automation tasks.

from pyvigate.core.engine import PlaywrightEngine

engine = PlaywrightEngine(headless=True)
await engine.start_browser()

QueryEngine (with Azure OpenAI)

QueryEngine incorporates AI to dynamically detect web page elements, significantly improving the efficiency and reliability of automated interactions. It also can help the user navigate and also create their own applications, which involve curating data, creating RAG applications, product tour, functional testing, etc.

from pyvigate.ai.query_engine import QueryEngine

query_engine = QueryEngine(
    api_key=os.getenv("OPENAI_API_KEY"),
    api_version=os.getenv("AZURE_API_VERSION"),
    azure_endpoint=os.getenv("AZURE_ENDPOINT"),
    llm_deployment_name=os.getenv("LLM_DEPLOYMENT_NAME"),
    embedding_deployment_name=os.getenv("EMBEDDING_DEPLOYMENT_NAME")
)

Login

Some products can be accessed by the browser only after the login. We can do this either manually identifying the login selectors or letting the AI detect the UI elements where the credentials can be passed.The Login component utilizes QueryEngine to intelligently identify login forms and fields, streamlining the login process.

from pyvigate.core.login import Login

login = Login(query_engine)
await login.perform_login(engine.page, "https://example.com/login", "username", "password")

Scraping

With Scraping, Pyvigate offers powerful data extraction capabilities, enabling the collection of content from web pages post-login or navigation.

from pyvigate.services.scraping import Scraping

scraping = Scraping(data_dir="data")
content = await scraping.extract_data_from_page(engine.page)
print("Scraped content:", content)

Caching

The Caching component allows for the local storage of web page content, facilitating offline analysis and reducing bandwidth usage.

from pyvigate.services.caching import Caching

caching = Caching(cache_dir="html_cache")
await caching.cache_page_content(engine.page, "https://example.com/page")

Full Example

Bringing it all together, here's how you can use Pyvigate to login, scrape content, and cache it:

import asyncio
from dotenv import load_dotenv
from pyvigate.core.engine import PlaywrightEngine
from pyvigate.core.login import Login
from pyvigate.services.scraping import Scraping
from pyvigate.services.caching import Caching
from pyvigate.ai.query_engine import QueryEngine
import os

load_dotenv()

async def login_and_scrape():
    engine = PlaywrightEngine(headless=True)
    await engine.start_browser()

    query_engine = QueryEngine(api_key=os.getenv("OPENAI_API_KEY"))
    login = Login(query_engine)
    await login.perform_login(engine.page, "https://example.com/login", os.getenv("USERNAME"), os.getenv("PASSWORD"))

    scraping = Scraping(data_dir="data")
    content = await scraping.extract_data_from_page(engine.page)
    print("Scraped content:", content)

    caching = Caching(cache_dir="html_cache")
    await caching.cache_page_content(engine.page, "https://example.com/dashboard")

    await engine.stop_browser()

if __name__ == "__main__":
    asyncio.run(login_and_scrape())

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

pyvigate-0.0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pyvigate-0.0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file pyvigate-0.0.2.tar.gz.

File metadata

  • Download URL: pyvigate-0.0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.16

File hashes

Hashes for pyvigate-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9a557b2d89b3b1534a812336d3234dc3aa287ffdd2a1ee27723c3c1b8165eb40
MD5 72ec7deedc91fb3dbd7870e8fcaae0e9
BLAKE2b-256 b222f8fd113855f2c56eb29974811ed7ee26db73db271e6bee4a392a2139e763

See more details on using hashes here.

File details

Details for the file pyvigate-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyvigate-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.16

File hashes

Hashes for pyvigate-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d144bbd1e419c2a16f3ab450ae3b4aacceb5965f7237b2cfffb4cf81134746e5
MD5 da47693635922f72e05d28fa5adfc5db
BLAKE2b-256 a09fe4cc71eea23cc70a8591ca82a57b547825f47ff9e16486f96f090bbab55c

See more details on using hashes here.

Supported by

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