initial commit
This commit is contained in:
commit
f0a6f9eb1e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1798
Cargo.lock
generated
Normal file
1798
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "grrs"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = {version = "4.2.7", features = ["derive"]}
|
||||
reqwest = { version = "0.11.17", features = ["blocking", "json"]}
|
||||
scraper = { version = "0.16.0", features = []}
|
24
src/main.rs
Normal file
24
src/main.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use clap::Parser;
|
||||
use scraper::{Html, Selector};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
url: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Cli::parse();
|
||||
|
||||
let res = reqwest::blocking::get(&args.url).expect("");
|
||||
let raw_html_text = res.text().unwrap();
|
||||
|
||||
let fragment = Html::parse_fragment(&raw_html_text);
|
||||
let title_selector = Selector::parse("title").unwrap();
|
||||
let title = fragment.select(&title_selector).next().unwrap();
|
||||
|
||||
let title = title.inner_html();
|
||||
println!("{}", title.trim());
|
||||
|
||||
// println!("[[{}][{}]]", args.url, title.trim());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user