Add timeout

This commit is contained in:
Mylloon 2024-12-29 20:40:18 +01:00
parent 400a927ce1
commit 400f1c0d25
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,4 +1,4 @@
use std::{collections::HashMap, sync::Arc};
use std::{collections::HashMap, sync::Arc, time::Duration};
use chrono::{Datelike, Utc};
use scraper::Html;
@ -123,7 +123,13 @@ pub async fn get_webpage(
// Use custom User-Agent
let client = reqwest::Client::builder().user_agent(user_agent).build()?;
let html = client.get(&url).send().await?.text().await?;
let html = client
.get(&url)
.timeout(Duration::from_secs(5))
.send()
.await?
.text()
.await?;
// Panic on error
crate::utils::check_errors(&html, &url);