From cd7b5434e66c13385ea9032fd6a78a88f513603a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 20 Aug 2022 20:24:19 +0200 Subject: [PATCH] return a tuple --- src/parse.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 3f74beb..03bffd0 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,16 +1,12 @@ use scraper::{Html, Selector}; /// Return vector of all the posts of the user -pub async fn get_posts(scheme: String, username: String, domain: String) -> Vec { +pub async fn get_posts(scheme: String, username: String, domain: String) -> (String, Vec) { + // Defines the address + let url = format!("{}://{}.{}", scheme, username, domain); + // Parse index page: sheme://username.domain - let document = Html::parse_document( - &reqwest::get(format!("{}://{}.{}", scheme, username, domain)) - .await - .unwrap() - .text() - .await - .unwrap(), - ); + let document = Html::parse_document(&reqwest::get(&url).await.unwrap().text().await.unwrap()); // Look at the posts let raw_posts = document @@ -25,5 +21,5 @@ pub async fn get_posts(scheme: String, username: String, domain: String) -> Vec< } // Return the vector - posts + (url, posts) }