From 5673ab336ed094a5b8d14371b71d39c626c41852 Mon Sep 17 00:00:00 2001 From: Max Mindlin Date: Sun, 16 Jun 2024 15:23:59 -0400 Subject: [PATCH] port opt --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index cecb6b9..682a7c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,9 @@ struct Args { #[arg(long)] debug: bool, + + #[arg(short, long, default_value_t = 4444)] + port: usize, } async fn run( @@ -51,7 +54,7 @@ async fn main() { let child = Command::new("geckodriver") .arg("--port") - .arg("4444") + .arg(args.port.to_string()) .stdout(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) .spawn() @@ -65,9 +68,10 @@ async fn main() { let opts = serde_json::json!({ "args": ["--headless"] }); caps.insert("moz:firefoxOptions".into(), opts); } + let conn_url = format!("http://localhost:{}", args.port); let crawler = fantoccini::ClientBuilder::native() .capabilities(caps) - .connect("http://localhost:4444") + .connect(&conn_url) .await .expect("error starting browser");