File: main.rs

package info (click to toggle)
python-setuptools-rust 1.9.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 648 kB
  • sloc: python: 1,703; javascript: 95; sh: 14; makefile: 13
file content (27 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Pure rust version for comparing with python based calls

use kuchiki;

use std::env;
use std::path::PathBuf;
use std::time::Instant;
use tendril::stream::TendrilSink;

fn main() {
    let path = PathBuf::from(
        env::args()
            .nth(1)
            .expect("You need to pass the file name as first argument"),
    );

    let now = Instant::now();
    let document = kuchiki::parse_html().from_utf8().from_file(&path).unwrap();
    println!("{:?}", now.elapsed());
    let now2 = Instant::now();
    let links: Vec<String> = document
        .select("a[href]")
        .unwrap()
        .map(|css_match| css_match.text_contents())
        .collect();
    println!("{} {:?}", links.len(), now2.elapsed());
}