reverse ordering, fix duplicate output
This commit is contained in:
+8
-3
@@ -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<Item = ElementRef> {
|
||||
// `Select` does not implement DoubleEndedIterator, so we need to collect it first
|
||||
let mut result = html.select(&self.departure).collect::<Vec<_>>();
|
||||
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> {
|
||||
|
||||
+1
-1
@@ -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<String> {
|
||||
match ureq::get(SIEDLUNG).call() {
|
||||
|
||||
Reference in New Issue
Block a user