Skip to content

Commit

Permalink
Consolidate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
causal-agent committed Jan 16, 2016
1 parent 6cb7c4d commit 55891ae
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 70 deletions.
28 changes: 28 additions & 0 deletions examples/document.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extern crate scraper;

use std::io::{self, Read, Write};

use scraper::{Selector, Html};

fn main() {
let mut input = String::new();
let mut stdout = io::stdout();
let mut stdin = io::stdin();

write!(stdout, "CSS selector: ").unwrap();
stdout.flush().unwrap();
stdin.read_line(&mut input).unwrap();
let selector = Selector::parse(&input).unwrap();

write!(stdout, "HTML document:\n").unwrap();
stdout.flush().unwrap();
input.clear();
stdin.read_to_string(&mut input).unwrap();
let document = Html::parse_document(&input);

println!("{:#?}", document);

for node in document.select(&selector) {
println!("{:?}", node.value());
}
}
28 changes: 28 additions & 0 deletions examples/fragment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extern crate scraper;

use std::io::{self, Read, Write};

use scraper::{Selector, Html};

fn main() {
let mut input = String::new();
let mut stdout = io::stdout();
let mut stdin = io::stdin();

write!(stdout, "CSS selector: ").unwrap();
stdout.flush().unwrap();
stdin.read_line(&mut input).unwrap();
let selector = Selector::parse(&input).unwrap();

write!(stdout, "HTML fragment:\n").unwrap();
stdout.flush().unwrap();
input.clear();
stdin.read_to_string(&mut input).unwrap();
let fragment = Html::parse_fragment(&input);

println!("{:#?}", fragment);

for node in fragment.select(&selector) {
println!("{:?}", node.value());
}
}
12 changes: 0 additions & 12 deletions examples/parse_document.rs

This file was deleted.

12 changes: 0 additions & 12 deletions examples/parse_fragment.rs

This file was deleted.

12 changes: 0 additions & 12 deletions examples/parse_selector.rs

This file was deleted.

34 changes: 0 additions & 34 deletions examples/select.rs

This file was deleted.

0 comments on commit 55891ae

Please sign in to comment.