Skip to content
Snippets Groups Projects
Commit ca73f519 authored by Marvin Weiler's avatar Marvin Weiler
Browse files

Removed the gecodriver

Removed the geckodriver binary.
Removed the "autostart" of the gecodriver on startup.
The config.json now expects a webdriver_url parameter on where to find a webdriver
parent 75b960e0
No related branches found
No related tags found
No related merge requests found
{"smtp_host":"","smtp_user":"","smtp_pass":"","smtp_from":"","filters":[],"recipients":[]}
{ "webdriver_url" = "localhost:4444", "smtp_host":"","smtp_user":"","smtp_pass":"","smtp_from":"","filters":[],"recipients":[]}
File deleted
......@@ -3,7 +3,6 @@ use fantoccini::{ClientBuilder, Locator};
use lettre::transport::smtp::authentication::{Credentials, Mechanism};
use lettre::{Message, SmtpTransport, Transport};
use penguin_config::*;
use std::process::Command;
struct Product {
name: String,
......@@ -14,6 +13,7 @@ struct Product {
#[derive(Deserialize, PenguinConfigFile, Default)]
#[penguin_config(path = "config.json")]
struct Config {
webdriver_url: String,
smtp_host: String,
smtp_user: String,
smtp_pass: String,
......@@ -27,7 +27,7 @@ async fn main() {
let config = Config::read_config();
let filters = &config.filters;
let products = get_html_products().await.unwrap();
let products = get_html_products(&config).await.unwrap();
let filtered: Vec<Product> = products
.into_iter()
......@@ -49,18 +49,12 @@ async fn main() {
}
}
async fn get_html_products() -> Result<Vec<Product>, CmdError> {
async fn get_html_products(config: &Config) -> Result<Vec<Product>, CmdError> {
println!("Fetching items from amd Website");
// start the geckodriver
let mut geckodriver = Command::new("sh")
.arg("-c")
.arg("./geckodriver --log fatal")
.spawn()
.expect("sh command failed to start geckodriver");
// navigate to amd-site
let mut webc = ClientBuilder::native()
.connect("http://localhost:4444")
.connect(config.webdriver_url.as_str())
.await
.expect("failed to connect to WebDriver");
webc.goto("https://www.amd.com/de/direct-buy/de")
......@@ -94,8 +88,6 @@ async fn get_html_products() -> Result<Vec<Product>, CmdError> {
.await
.expect("Failed to terminate webdriver sessions");
// stop the geckodriver
geckodriver.kill().expect("Failed to kill geckodriver!");
return Ok(products);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment