1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
use fetch::fetch_schedules_in_stop; use parser::parse_html; use error::ScraperError; mod error; mod fetch; mod parser; #[derive(Debug, PartialEq)] pub struct Schedule { line: String, time: String, destination: String, stop: String, } /// Fetches the schedules given a stop. /// `stop_code` is the code given by STCP to the stop. You can check it in the `Código` part of the table for line 200 here: https://www.stcp.pt/pt/viajar/linhas/?linha=200 pub fn fetch_next_buses(stop_code: &str) -> Result<Vec<Schedule>, ScraperError> { let html = fetch_schedules_in_stop(stop_code, None)?; let result = parse_html(stop_code, &html)?; Ok(result) }