utkarshkukreti / select.rs

A Rust library to extract useful data from HTML documents, suitable for web scraping.
MIT License
971 stars 69 forks source link

Example from README isn't compilable #25

Closed php-coder closed 7 years ago

php-coder commented 8 years ago

Looks like example outdated because I couldn't compile it:

src/main.rs:16:52: 16:62 error: no method named `descendant` found for type `select::predicate::Attr<&str, &str>` in the current scope
src/main.rs:16     for node in document.find(Attr("id", "hmenus").descendant(Name("a"))) {
                                                                  ^~~~~~~~~~
src/main.rs:22:58: 22:62 error: no method named `take` found for type `select::selection::Selection<'_>` in the current scope
src/main.rs:22     for node in document.find(Class("question-summary")).take(5) {
                                                                        ^~~~
src/main.rs:22:58: 22:62 note: the method `take` exists but the following trait bounds were not satisfied: `select::selection::Selection<'_> : std::iter::Iterator`
src/main.rs:25:49: 25:59 error: no method named `descendant` found for type `select::predicate::Class<&str>` in the current scope
src/main.rs:25         let answers = node.find(Class("status").descendant(Name("strong")))
                                                               ^~~~~~~~~~
src/main.rs:31:53: 31:63 error: no method named `descendant` found for type `select::predicate::Class<&str>` in the current scope
src/main.rs:31         let asker = node.find(Class("user-details").descendant(Name("a")))
                                                                   ^~~~~~~~~~
src/main.rs:49:10: 49:16 error: no method named `unwrap` found for type `select::selection::Selection<'_>` in the current scope
src/main.rs:49         .unwrap()
                        ^~~~~~
error: aborting due to 5 previous errors
$ cargo --version
cargo 0.12.0-nightly (6b98d1f 2016-07-04)
$ rustc --version
rustc 1.11.0 (9b21dcd6a 2016-08-15)
utkarshkukreti commented 8 years ago

I updated the README for the next version of select.rs but I haven't gotten around to releasing it. For now, you can use the latest git version using:

[dependencies]
select = { git = "https://github.com/utkarshkukreti/select.rs" }

or follow the README from 0.3.0: https://github.com/utkarshkukreti/select.rs/tree/0.3.0

php-coder commented 8 years ago

Thanks, it worked!

Did you publish API docs somewhere?

utkarshkukreti commented 8 years ago

They're available on docs.rs: https://docs.rs/select/0.3.0/select/

Thanks for the reminder. I'll add this to the README soon.