initial commit

This commit is contained in:
inkch 2023-05-10 10:13:52 +09:00
commit f0a6f9eb1e
4 changed files with 1834 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1798
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
Cargo.toml Normal file
View 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
View 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());
}