1use scraper::{Html, Selector};
3
4#[tokio::main]
5
6pub async fn xchangeit(amount: Option<&str>, from: Option<&str>, to: Option<&str>) -> Result<(), Box<dyn std::error::Error>> {
8
9 let url_final = format!("https://www.xe.com/currencyconverter/convert/?Amount={:?}&From={:?}&To={:?}", amount.unwrap_or_default(), from.unwrap_or_default(), to.unwrap_or_default());
11
12 let url = url_final.replace("\"", "");
13
14 let req = reqwest::get(url).await?;
18
19 let fragment = Html::parse_fragment(&req.text().await?);
24
25 let selector = Selector::parse(".iGrAod").unwrap();
27
28 for elem in fragment.select(&selector) {
30 println!("{}", elem.text().collect::<String>().trim());
31 }
32
33 Ok(())
34
35}
36