All checks were successful
continuous-integration/drone/pr Build is passing
A builder for mediapart have been added. No generic builder have been created as there is no usecase yet. Some documentation have been added, roadmap and scope have been clarified and chatbot have been lightly documented.
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use std::convert::TryInto;
|
|
use std::env;
|
|
|
|
use anyhow::Result;
|
|
use crieur_retrieve::{
|
|
newspaper::Newspaper,
|
|
newspapers::mediapart::{self, Mediapart},
|
|
ArticleLocation, Url,
|
|
};
|
|
use dotenv::dotenv;
|
|
use log::info;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
dotenv().ok();
|
|
env_logger::init();
|
|
|
|
let url = match env::args().nth(1) {
|
|
Some(url) => Url::parse(&url)?,
|
|
None => "https://www.mediapart.fr/journal/france/030421/l-hotel-dieu-patients-et-medecins-tentent-de-percer-les-mysteres-du-covid-long".try_into()?,
|
|
};
|
|
|
|
// TODO: remove this in favor of default newspapers
|
|
|
|
let mpruiid = env::var("MEDIAPART_COOKIE")?.into();
|
|
let mediapart = Mediapart::builder()
|
|
.login(mediapart::Login::MPRUUID(mpruiid))
|
|
.build()?;
|
|
|
|
info!("Trying to download article from {}", url);
|
|
|
|
// TODO: shorten this, maybe an helper function ?
|
|
let article_location = ArticleLocation::builder()
|
|
.url(url)?
|
|
.newspaper(mediapart)
|
|
.build()?;
|
|
|
|
let article_str = article_location.retrieve_html().await?;
|
|
|
|
println!("{}", article_str);
|
|
|
|
Ok(())
|
|
}
|