refactor main

This commit is contained in:
Dr. Matthias Ratajczak
2022-12-15 16:06:53 +01:00
parent ed9d3d7c73
commit 40c0d3c2cc
3 changed files with 15 additions and 13 deletions
+3 -12
View File
@@ -1,15 +1,13 @@
mod extractor;
mod query;
use anyhow::{anyhow, Result};
use anyhow::Result;
use scraper::Html;
use extractor::Extractor;
const SIEDLUNG: &str =
"https://www.vvo-online.de/de/fahrplan/aktuelle-abfahrten-ankuenfte/abfahrten?stopid=33006764";
fn main() -> Result<()> {
let message = query_server()?;
let message = query::query_server()?;
let html = Html::parse_document(&message);
let extractor = Extractor::new();
@@ -21,10 +19,3 @@ fn main() -> Result<()> {
}
Ok(())
}
fn query_server() -> Result<String> {
match ureq::get(SIEDLUNG).call() {
Ok(response) => Ok(response.into_string().map_err(|e| anyhow!(e))?),
Err(e) => Err(anyhow!(e)),
}
}
+11
View File
@@ -0,0 +1,11 @@
use anyhow::{anyhow, Result};
pub(crate) const SIEDLUNG: &str =
"https://www.vvo-online.de/de/fahrplan/aktuelle-abfahrten-ankuenfte/abfahrten?stopid=33006764";
pub(crate) fn query_server() -> Result<String> {
match ureq::get(SIEDLUNG).call() {
Ok(response) => Ok(response.into_string().map_err(|e| anyhow!(e))?),
Err(e) => Err(anyhow!(e)),
}
}