summaryrefslogtreecommitdiff
path: root/src/web.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-09 23:34:40 -0800
committerFuwn <[email protected]>2024-01-09 23:34:40 -0800
commitfa9f5f70a5221bb940354f3e4d978d4312af77e4 (patch)
tree06a8fd1e6c254fae373459a606bf3b256ccb8efe /src/web.rs
downloadrin-fa9f5f70a5221bb940354f3e4d978d4312af77e4.tar.xz
rin-fa9f5f70a5221bb940354f3e4d978d4312af77e4.zip
feat: initial release
Diffstat (limited to 'src/web.rs')
-rw-r--r--src/web.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/web.rs b/src/web.rs
new file mode 100644
index 0000000..eb10ff2
--- /dev/null
+++ b/src/web.rs
@@ -0,0 +1,27 @@
+use {thirtyfour::WebDriver, tokio::process::Command};
+
+pub fn geckodriver() -> Result<tokio::process::Child, std::io::Error> {
+ Command::new("geckodriver")
+ .arg("--port=9515")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+}
+
+pub async fn webdriver() -> Result<WebDriver, thirtyfour::error::WebDriverError>
+{
+ let mut caps = thirtyfour::DesiredCapabilities::firefox();
+
+ caps.set_headless().expect("failed to set headless");
+
+ let driver = WebDriver::new("http://localhost:9515", caps)
+ .await
+ .expect("failed to connect to webdriver");
+
+ driver
+ .goto("https://due.moe/schedule")
+ .await
+ .expect("failed to navigate to https://due.moe/schedule");
+
+ Ok(driver)
+}