forked from danmax/r34-scraper
feat: add arg parsing
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -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 {
|
||||
|
Reference in New Issue
Block a user