forked from Anri/cal8tor
Add timeout
This commit is contained in:
parent
400a927ce1
commit
400f1c0d25
1 changed files with 8 additions and 2 deletions
10
src/utils.rs
10
src/utils.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use chrono::{Datelike, Utc};
|
use chrono::{Datelike, Utc};
|
||||||
use scraper::Html;
|
use scraper::Html;
|
||||||
|
@ -123,7 +123,13 @@ pub async fn get_webpage(
|
||||||
|
|
||||||
// Use custom User-Agent
|
// Use custom User-Agent
|
||||||
let client = reqwest::Client::builder().user_agent(user_agent).build()?;
|
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
|
// Panic on error
|
||||||
crate::utils::check_errors(&html, &url);
|
crate::utils::check_errors(&html, &url);
|
||||||
|
|
Loading…
Reference in a new issue