diff options
| author | Fuwn <[email protected]> | 2024-01-09 23:34:40 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-09 23:34:40 -0800 |
| commit | fa9f5f70a5221bb940354f3e4d978d4312af77e4 (patch) | |
| tree | 06a8fd1e6c254fae373459a606bf3b256ccb8efe /src/web.rs | |
| download | rin-fa9f5f70a5221bb940354f3e4d978d4312af77e4.tar.xz rin-fa9f5f70a5221bb940354f3e4d978d4312af77e4.zip | |
feat: initial release
Diffstat (limited to 'src/web.rs')
| -rw-r--r-- | src/web.rs | 27 |
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) +} |