From effd567fa5ba2237fb4b064cf6bcd8e5d6b24f4a Mon Sep 17 00:00:00 2001 From: linlkin Date: Fri, 6 Dec 2024 04:59:22 +0100 Subject: [PATCH] force a toi lukian --- back/Cargo.toml | 2 ++ back/src/create_db.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/back/Cargo.toml b/back/Cargo.toml index 6be9ee0..7df2455 100644 --- a/back/Cargo.toml +++ b/back/Cargo.toml @@ -9,4 +9,6 @@ actix-web = "4" sqlite = "0.36.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.133" +rss = "2.0.11" +reqwest = "0.12.9" diff --git a/back/src/create_db.rs b/back/src/create_db.rs index 21cb84a..f36e5ee 100644 --- a/back/src/create_db.rs +++ b/back/src/create_db.rs @@ -1,4 +1,6 @@ use sqlite::{Connection, OpenFlags}; +use rss::{Channel, Item}; +use reqwest; pub fn init() -> sqlite::Result<()> { let conn = Connection::open_with_flags( @@ -21,3 +23,18 @@ pub fn init() -> sqlite::Result<()> { Ok(()) } + +pub async fn update_articles( channel: &Channel) { + let conn = Connection::open_with_flags( + "./data/data.db", + OpenFlags::new() + .with_create() + .with_read_write() + ); + + let flux_rss = reqwest::get("https://www.lemonde.fr/rss/une.xml") + .await + .unwrap(); + + let channel = Channel::read_from(&flux_rss[..]); +}