generated from OBJNULL/Dockerized-Rust
Backend properly implements TOKIO & Scraper
This commit is contained in:
parent
9892b663d2
commit
80c6b51d01
1 changed files with 13 additions and 5 deletions
|
@ -1,8 +1,9 @@
|
||||||
// Libraries
|
// Libraries
|
||||||
mod calculator;
|
mod calculator;
|
||||||
use std::io::Result;
|
mod scraper;
|
||||||
|
|
||||||
use calculator::{CalculationResult, Calculator};
|
use calculator::{CalculationResult, Calculator};
|
||||||
|
use scraper::Scraper;
|
||||||
|
use std::io::Result;
|
||||||
|
|
||||||
// Structures
|
// Structures
|
||||||
pub struct Backend {
|
pub struct Backend {
|
||||||
|
@ -22,11 +23,18 @@ impl Backend {
|
||||||
/// ```rs
|
/// ```rs
|
||||||
/// let backend = Backend::new(true)?;
|
/// let backend = Backend::new(true)?;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(fetch: bool) -> Result<Self> {
|
pub async fn new(fetch: bool) -> Result<Self> {
|
||||||
// Did we want to fetch our prices?
|
// Did we want to fetch our prices?
|
||||||
let memberships: Vec<String> = if fetch {
|
let memberships: Vec<String> = if fetch {
|
||||||
// Use Internet to get prices
|
// Getting the URL to scrape from
|
||||||
unimplemented!("TODO: Implement online Membership Price Fetching");
|
let scrape_url =
|
||||||
|
"https://www.washluberepair.com/location/frederick-auto-spa-express-rt-85/";
|
||||||
|
|
||||||
|
// Fetching with our Scraper
|
||||||
|
let scraper = Scraper::new(scrape_url);
|
||||||
|
|
||||||
|
// Scraping
|
||||||
|
scraper.start().await?
|
||||||
} else {
|
} else {
|
||||||
// Manually creating our prices
|
// Manually creating our prices
|
||||||
vec![
|
vec![
|
||||||
|
|
Loading…
Reference in a new issue