web-scrapingrustrust-tokiounwrapreqwest

why am i getting an error that is running for others in rust reqwest?


I an trying to build a webscraper via rust using reqwest library. reqwest = "0.11.10" scraper = "0.12.0"

I saw the example here: https://kadekillary.work/post/webscraping-rust/ I tried to do the same thing, but i am getting an error.

My code: `

    extern crate reqwest;
    extern crate scraper;

use scraper::{Html,Selector};

fn main() {
    println!("WELCOME!");
    scrape_the_news("https://www.examplewebsite.com");
}

fn scrape_the_news(url: &str) {
    let mut urlsource = reqwest::get(url).unwrap();
    assert!(resp.status().is_success());

}

`

I am getting an error, the error is: no method named unwrap found for opaque type impl Future<Output = Result<Response, reqwest::Error>> in the current scope

Thank you


Solution

  • The example you use is outdated.

    I suggest you to get the examples from the official project : https://github.com/seanmonstar/reqwest/blob/master/examples/simple.rs