Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/managedcode/KernelMemory.Playwright
https://github.com/managedcode/KernelMemory.Playwright
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/managedcode/KernelMemory.Playwright
- Owner: managedcode
- License: mit
- Created: 2024-01-30T10:56:44.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-03T13:33:08.000Z (9 months ago)
- Last Synced: 2024-05-01T11:26:15.939Z (6 months ago)
- Language: C#
- Size: 46.9 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-semantickernel - KernelMemory.Playwright is an open-source project that provides methods to import websites as text or images into memory
README
# KernelMemory.Playwright
KernelMemory.Playwright is an open-source project that provides methods to import websites as text or images into memory. It leverages the power of the Playwright library to interact with web pages programmatically.
[![NuGet Package](https://img.shields.io/nuget/v/ManagedCode.KernelMemory.Playwright.svg)](https://www.nuget.org/packages/ManagedCode.KernelMemory.Playwright)
## Features
- Import web pages as text: This feature allows you to fetch the entire text content of a web page and store it in memory.
- Import web pages as images: This feature enables you to take a screenshot of a web page and store it in memory.## How to Use
1. Install the package into your project.
You can install the `ManagedCode.KernelMemory.Playwright` NuGet package by running the following command in your terminal:
```bash
dotnet add package ManagedCode.KernelMemory.Playwright
```Add Playwright to your services.
```csharp
services.WithPlaywright();
```2. Use the `ImportWebPageAsTextWithPlaywrightAsync` or `ImportWebPageAsImageWithPlaywrightAsync` methods to import a web page as text or image respectively.
## Example
```csharp
// Import a web page as text
string documentId = await memory.ImportWebPageAsTextWithPlaywrightAsync("https://example.com");// Import a web page as an image
string documentId = await memory.ImportWebPageAsImageWithPlaywrightAsync("https://example.com");// Get the content of a web page as text
string pageText = await memory.GetWebPageContentAsTextAsync("https://example.com");// Get the content of a web page as an image
byte[] pageImage = await memory.GetWebPageContentAsImageAsync("https://example.com");
```