pub struct HtmlInfo {
pub title: Option<String>,
pub description: Option<String>,
pub canonical_url: Option<String>,
pub feed_url: Option<String>,
pub language: Option<String>,
pub text_content: String,
pub meta: HashMap<String, String>,
pub opengraph: Opengraph,
pub schema_org: Vec<SchemaOrg>,
pub links: Vec<Link>,
}Expand description
Parsed HTML document information.
Fields§
§title: Option<String>Document title from <title> tag
description: Option<String>Meta description
canonical_url: Option<String>Canonical URL from <link rel="canonical">
feed_url: Option<String>RSS/Atom feed URL from <link rel="alternate" type="application/rss+xml">
language: Option<String>Document language from <html lang="...">
text_content: StringText content extracted from the body (tags stripped)
meta: HashMap<String, String>All meta tags as key-value pairs
opengraph: OpengraphOpenGraph metadata
schema_org: Vec<SchemaOrg>Schema.org structured data (JSON-LD)
links: Vec<Link>All links found in the document
Implementations§
Source§impl HtmlInfo
impl HtmlInfo
Sourcepub fn from_string(html: &str, base_url: Option<&str>) -> Result<Self>
pub fn from_string(html: &str, base_url: Option<&str>) -> Result<Self>
Parse HTML from a string.
§Arguments
html- The HTML content to parsebase_url- Optional base URL for resolving relative links
§Example
use webpage_info::HtmlInfo;
let html = "<html><head><title>Hello</title></head><body>World</body></html>";
let info = HtmlInfo::from_string(html, None).unwrap();
assert_eq!(info.title, Some("Hello".to_string()));Trait Implementations§
Source§impl<'de> Deserialize<'de> for HtmlInfo
impl<'de> Deserialize<'de> for HtmlInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HtmlInfo
impl RefUnwindSafe for HtmlInfo
impl Send for HtmlInfo
impl Sync for HtmlInfo
impl Unpin for HtmlInfo
impl UnwindSafe for HtmlInfo
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