forked from rust-scraper/scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cb7c4d
commit 55891ae
Showing
6 changed files
with
56 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.