Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cargo.toml → Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
workspace.resolver = "2"
resolver = "2"
members = ["scraper", "airbnb"]
14 changes: 8 additions & 6 deletions airbnb/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<dyn Error>> {
let driver = initialize_driver().await?;
Expand Down Expand Up @@ -33,15 +36,15 @@ async fn scrape_all(driver: WebDriver) -> Result<(), Box<dyn Error>> {

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)?;

}
Expand Down Expand Up @@ -69,7 +72,6 @@ async fn load_next_page(
next_page_button: WebElement,
driver: &WebDriver,
) -> Result<(), Box<dyn Error>> {

next_page_button.click().await?;
thread::sleep(Duration::from_secs(2));

Expand Down
4 changes: 2 additions & 2 deletions scraper/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(),Box<dyn Error>>{
async fn main() -> Result<(), Box<dyn Error>> {
airbnb::scrape_airbnb("Rome").await?;
Ok(())
}
}