mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-25 02:13:41 +00:00
Run every 20 minutes, send user agent
This commit is contained in:
parent
c20a2a3a88
commit
25cef90288
2 changed files with 11 additions and 3 deletions
12
src/items.rs
12
src/items.rs
|
@ -1,3 +1,4 @@
|
|||
use reqwest::Client;
|
||||
use scraper::{Html, Selector};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use worker::*;
|
||||
|
@ -24,10 +25,17 @@ pub struct ShopItem {
|
|||
|
||||
pub type ShopItems = Vec<ShopItem>;
|
||||
|
||||
pub async fn try_fetch(shop_url: Url) -> Result<ShopItems> {
|
||||
let mut response = Fetch::Url(shop_url).send().await?;
|
||||
const USER_AGENT: &str = "Arcade-Monitor/1.0 (+@SkyfallWasTaken)";
|
||||
|
||||
pub async fn try_fetch(shop_url: Url) -> Result<ShopItems> {
|
||||
let client = Client::new();
|
||||
let response = client
|
||||
.get(shop_url)
|
||||
.header("User-Agent", USER_AGENT)
|
||||
.send()
|
||||
.await?;
|
||||
let doc_html = response.text().await?;
|
||||
|
||||
let doc = Html::parse_document(&doc_html);
|
||||
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
|
||||
let json: serde_json::Value = serde_json::from_str(
|
||||
|
|
|
@ -6,7 +6,7 @@ compatibility_date = "2024-06-29"
|
|||
command = "cargo install worker-build && worker-build --release"
|
||||
|
||||
[triggers]
|
||||
crons = ["0 * * * *"] # Run every hour
|
||||
crons = ["*/20 * * * *"] # Run every twenty minutes
|
||||
|
||||
[placement]
|
||||
mode = "smart"
|
||||
|
|
Loading…
Reference in a new issue