Skip to content

Commit

Permalink
#5 Add skelbiu-lt listing price scraping
Browse files Browse the repository at this point in the history
  • Loading branch information
zexa committed Oct 11, 2021
1 parent da8e8a0 commit 537df8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions skelbiu-lt-scraper/src/skelbiu_lt_listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct SkelbiuLtListing {
liked_amount: String,
location: String,
quality: String,
price: String,
}

impl SkelbiuLtListing {
Expand All @@ -24,6 +25,7 @@ impl SkelbiuLtListing {
liked_amount: String,
location: String,
quality: String,
price: String,
) -> Self {
Self {
url,
Expand All @@ -35,6 +37,7 @@ impl SkelbiuLtListing {
liked_amount,
location,
quality,
price,
}
}

Expand Down Expand Up @@ -69,6 +72,10 @@ impl SkelbiuLtListing {
pub fn get_quality(&self) -> &str {
&self.quality
}

pub fn get_price(&self) -> &str {
&self.price
}
}

impl Listing for SkelbiuLtListing {
Expand Down
14 changes: 14 additions & 0 deletions skelbiu-lt-scraper/src/skelbiu_lt_listing_scraper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct SkelbiuLtListingScraper {
liked_amount_selector: Selector,
location_selector: Selector,
quality_selector: Selector,
price_selector: Selector,
}

impl SkelbiuLtListingScraper {
Expand All @@ -24,6 +25,7 @@ impl SkelbiuLtListingScraper {
liked_amount_selector: &str,
location_selector: &str,
quality_selector: &str,
price_selector: &str,
) -> Self {
let id_selector = Selector::parse(id_selector).unwrap();
let title_selector = Selector::parse(title_selector).unwrap();
Expand All @@ -33,6 +35,7 @@ impl SkelbiuLtListingScraper {
let liked_amount_selector = Selector::parse(liked_amount_selector).unwrap();
let location_selector = Selector::parse(location_selector).unwrap();
let quality_selector = Selector::parse(quality_selector).unwrap();
let price_selector = Selector::parse(price_selector).unwrap();

Self {
id_selector,
Expand All @@ -43,6 +46,7 @@ impl SkelbiuLtListingScraper {
liked_amount_selector,
location_selector,
quality_selector,
price_selector,
}
}
}
Expand Down Expand Up @@ -126,6 +130,15 @@ impl ListingScraper<SkelbiuLtListing> for SkelbiuLtListingScraper {
.trim()
.to_string();

let price = html
.select(&self.price_selector)
.next()
.unwrap()
.text()
.collect::<String>()
.trim()
.to_string();

return Some(SkelbiuLtListing::new(
listing_url,
id,
Expand All @@ -136,6 +149,7 @@ impl ListingScraper<SkelbiuLtListing> for SkelbiuLtListingScraper {
liked_amount,
location,
quality,
price,
));
}

Expand Down
1 change: 1 addition & 0 deletions skelbiu-lt-scraper/src/skelbiu_lt_scraper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl CommonScrapper<SkelbiuLtListing> for SkelbiuLtScraper {
".bookmarks",
".cities",
".value:not(.js-monthly-payment)",
".price",
))
}

Expand Down

0 comments on commit 537df8d

Please sign in to comment.