diff --git a/cargo.toml b/Cargo.toml similarity index 63% rename from cargo.toml rename to Cargo.toml index 9fc72b5..5cec0c7 100644 --- a/cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] -workspace.resolver = "2" +resolver = "2" members = ["scraper", "airbnb"] diff --git a/airbnb/src/lib.rs b/airbnb/src/lib.rs index 57a6f7b..bd8e19d 100644 --- a/airbnb/src/lib.rs +++ b/airbnb/src/lib.rs @@ -1,9 +1,12 @@ +use serde::Serialize; use std::error::Error; use std::thread; use std::time::Duration; -use thirtyfour::{prelude::{WebDriverError, ElementWaitable}, By, DesiredCapabilities, WebDriver, WebElement}; +use thirtyfour::{ + prelude::{ElementWaitable, WebDriverError}, + By, DesiredCapabilities, WebDriver, WebElement, +}; use url::Url; -use serde::Serialize; pub async fn scrape_airbnb(place: &str) -> Result<(), Box> { let driver = initialize_driver().await?; @@ -33,15 +36,15 @@ async fn scrape_all(driver: WebDriver) -> Result<(), Box> { match next_page_button.is_clickable().await? { true => { - + //start extracting data - + let house_elems = get_house_elements(&driver).await?; for house_elem in house_elems { let bnb_details = BnbDetails::from(house_elem).await?; - + wtr.serialize(bnb_details)?; } @@ -69,7 +72,6 @@ async fn load_next_page( next_page_button: WebElement, driver: &WebDriver, ) -> Result<(), Box> { - next_page_button.click().await?; thread::sleep(Duration::from_secs(2)); diff --git a/scraper/src/main.rs b/scraper/src/main.rs index 3b84fcb..141a702 100644 --- a/scraper/src/main.rs +++ b/scraper/src/main.rs @@ -1,7 +1,7 @@ use std::error::Error; #[tokio::main] -async fn main() -> Result<(),Box>{ +async fn main() -> Result<(), Box> { airbnb::scrape_airbnb("Rome").await?; Ok(()) -} \ No newline at end of file +}