Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no method named next_sibling_element found for struct ElementRef<'_> in the current scope #106

Closed
thelastfantasy opened this issue Feb 22, 2023 · 2 comments

Comments

@thelastfantasy
Copy link

thelastfantasy commented Feb 22, 2023

use reqwest::Client;
use scraper::{Html, Selector};
use selectors::Element;

let url = "https://www.kansou.me/";
let client = Client::new();
let res = client.get(url).send().await?;

if !res.status().is_success() {
    return Err(Box::new(ScraperResult::Error(
        res.status().as_u16(),
        res.status().to_string(),
    )));
}

let body = res.text().await?;
let html = Html::parse_document(&body);
let h2_selector = Selector::parse("h2").unwrap();
let mut table_element = h2_element.next_sibling_element().unwrap(); // error occured here

It can be solved with add this to Cargo.toml
selectors = "0.22.0"

and add this to source code
use selectors::Element;

But, only add 0.22.0 can sovle this problem, and the current version of selectors is already 0.24.0.

So, any other ideas to solve this problems?

@adamreichold
Copy link
Contributor

This is fixed by #98 which re-exports Element thereby avoiding the extra dependency.

@cfvescovo
Copy link
Collaborator

This is fixed by #98 which re-exports Element thereby avoiding the extra dependency.

Looks like we need to publish a new release soon, #98 was merged 2 months ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants