Skip to content

Commit 27499d3

Browse files
fix web scrape cuz im stupid as fuck
Signed-off-by: MrScarySpaceCat <me@mrscaryspacecat.dev>
1 parent f80c5ff commit 27499d3

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "agent-kitten"
3-
version = "3.4.0"
3+
version = "3.4.1"
44
edition = "2024"
55

66
[dependencies]

scripts/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
set -o allexport
33
source .env
44
set +o allexport
5-
RUST_BACKTRACE=1 cargo run
5+
RUST_BACKTRACE=full cargo run

src/commands/textgen/chat.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use bson::oid::ObjectId;
1515
use futures::FutureExt;
1616
use html_to_markdown_rs::convert;
1717
use mongodb::bson::doc;
18-
use playwright_rs::{Playwright, ScreenshotOptions};
18+
use playwright_rs::Playwright;
1919
use poise::{CreateReply, serenity_prelude as serenity};
2020
use serde_json::{Value, json};
2121
use serenity::builder::CreateEmbed;
@@ -215,16 +215,20 @@ pub async fn web_scrape(value: Value) -> Result<String, DynError> {
215215

216216
let playwright = Playwright::launch().await?;
217217
let ws_url = std::env::var("BROWSER_WS_URL").expect("Missing BROWSER_WS_URL");
218-
let browser = playwright.chromium().connect(ws_url.as_str(), None).await?;
218+
let browser = playwright
219+
.chromium()
220+
.connect_over_cdp(ws_url.as_str(), None)
221+
.await?;
219222
let page = browser.new_page().await?;
220223

221224
let _ = page.goto(url, None).await?;
222225

223226
let content = page.content().await?;
224227
let result = convert(content.as_str(), None)?;
225-
226228
let final_result = result.content.unwrap_or_default().trim().to_string();
227229

230+
browser.close().await?;
231+
228232
Ok(final_result)
229233
}
230234

0 commit comments

Comments
 (0)