return a tuple

This commit is contained in:
Mylloon 2022-08-20 20:24:19 +02:00
parent 86c9f50f01
commit cd7b5434e6
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,16 +1,12 @@
use scraper::{Html, Selector}; use scraper::{Html, Selector};
/// Return vector of all the posts of the user /// Return vector of all the posts of the user
pub async fn get_posts(scheme: String, username: String, domain: String) -> Vec<String> { pub async fn get_posts(scheme: String, username: String, domain: String) -> (String, Vec<String>) {
// Defines the address
let url = format!("{}://{}.{}", scheme, username, domain);
// Parse index page: sheme://username.domain // Parse index page: sheme://username.domain
let document = Html::parse_document( let document = Html::parse_document(&reqwest::get(&url).await.unwrap().text().await.unwrap());
&reqwest::get(format!("{}://{}.{}", scheme, username, domain))
.await
.unwrap()
.text()
.await
.unwrap(),
);
// Look at the posts // Look at the posts
let raw_posts = document let raw_posts = document
@ -25,5 +21,5 @@ pub async fn get_posts(scheme: String, username: String, domain: String) -> Vec<
} }
// Return the vector // Return the vector
posts (url, posts)
} }