feat: add arg parsing

This commit is contained in:
2024-10-18 18:50:40 +02:00
parent 4acaf0308c
commit e62d2cc186
3 changed files with 135 additions and 2 deletions

View File

@@ -1,13 +1,25 @@
#![feature(async_closure)]
use clap::Parser;
use regex::Regex;
use reqwest::Client;
use std::process::ExitCode;
use tokio::time::{sleep, Duration};
const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36";
#[derive(Parser)]
#[command(version)]
struct Args {
/// User Agent to use for requests
#[arg(
short,
default_value = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
)]
user_agent: String,
}
#[tokio::main]
async fn main() -> ExitCode {
let args = Args::parse();
println!("which tags do you want to scrape? ex: 1girls+1boys+yomama");
let tags = std::io::stdin()
.lines()
@@ -17,7 +29,7 @@ async fn main() -> ExitCode {
.trim()
.to_string();
let client = Client::builder().user_agent(USER_AGENT).build().unwrap();
let client = Client::builder().user_agent(args.user_agent).build().unwrap();
let mut page = 0;
loop {