diff --git a/src/extractor.rs b/src/extractor.rs index 88c8733..800432c 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use scraper::{Html, Selector}; +use scraper::{ElementRef, Html, Selector}; pub(crate) struct Extractor { pub time: Selector, @@ -28,8 +28,13 @@ impl Extractor { Selector::parse("span.late").unwrap() } - pub(crate) fn get_departures<'a>(&'a self, html: &'a Html) -> scraper::html::Select<'a, 'a> { - html.select(&self.departure) + pub(crate) fn get_departures<'a>(&'a self, html: &'a Html) -> impl Iterator { + // `Select` does not implement DoubleEndedIterator, so we need to collect it first + let mut result = html.select(&self.departure).collect::>(); + result.reverse(); + // we seem to extract the blocks twice with slightly different layout, so we discard half of them + result.truncate(result.len() / 2); + result.into_iter() } pub(crate) fn get_transport_line(departure_block: scraper::ElementRef) -> Result<&str> { diff --git a/src/query.rs b/src/query.rs index 51b8e83..60bb501 100644 --- a/src/query.rs +++ b/src/query.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Result}; pub(crate) const SIEDLUNG: &str = - "https://www.vvo-online.de/de/fahrplan/aktuelle-abfahrten-ankuenfte/abfahrten?stopid=33006764"; + "https://www.vvo-online.de/de/fahrplan/aktuelle-abfahrten-ankuenfte/abfahrten?stopid=33006765"; pub(crate) fn query_server() -> Result { match ureq::get(SIEDLUNG).call() {