Struct article_scraper::Readability
source · pub struct Readability;
Expand description
Rust port of mozilla readability algorithm
Used as fallback for ArticleScraper
if no fitting config can be found
Implementations§
source§impl Readability
impl Readability
sourcepub async fn extract(
html: &str,
base_url: Option<Url>
) -> Result<String, FullTextParserError>
pub async fn extract( html: &str, base_url: Option<Url> ) -> Result<String, FullTextParserError>
Parse HTML and extract meaningful content
§Arguments
html
- HTML of a website containing an article or similar contentbase_url
- URL used to complete relative URLs
§Examples
use url::Url;
use article_scraper::Readability;
async fn demo() {
let html = reqwest::get("https://www.nytimes.com/interactive/2023/04/21/science/parrots-video-chat-facetime.html")
.await
.unwrap()
.text()
.await
.unwrap();
let base_url = Url::parse("https://www.nytimes.com").unwrap();
let extracted_content = Readability::extract(&html, Some(base_url)).await.unwrap();
}
Auto Trait Implementations§
impl Freeze for Readability
impl RefUnwindSafe for Readability
impl Send for Readability
impl Sync for Readability
impl Unpin for Readability
impl UnwindSafe for Readability
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more