pub struct HtmlParser;Expand description
HTML parser that extracts structured data from raw HTML.
Stateless parser using the scraper crate for CSS selector-based
extraction. All methods are static and thread-safe.
§Examples
use crawlkit_engine::{HtmlParser, parser::ParseError};
use url::Url;
let html = r#"<!DOCTYPE html><html><head><title>Test</title></head>
<body><h1>Hello</h1><a href="/link">link</a></body></html>"#;
let url = Url::parse("https://example.com/page").unwrap();
let page = HtmlParser::parse(html, &url).unwrap();
assert_eq!(page.meta.title.as_deref(), Some("Test"));
assert_eq!(page.headings.len(), 1);
assert_eq!(page.links.len(), 1);Implementations§
Source§impl HtmlParser
impl HtmlParser
Sourcepub fn parse(html: &str, url: &Url) -> Result<ParsedPage, ParseError>
pub fn parse(html: &str, url: &Url) -> Result<ParsedPage, ParseError>
Parse an HTML document and extract all SEO-relevant data.
Extracts meta tags, headings, links, images, forms, scripts, stylesheets, structured data (JSON-LD), accessibility landmarks, and social media metadata.
§Errors
Currently always returns Ok. The ParseError type is reserved
for future selector compilation or URL resolution failures.
Auto Trait Implementations§
impl Freeze for HtmlParser
impl RefUnwindSafe for HtmlParser
impl Send for HtmlParser
impl Sync for HtmlParser
impl Unpin for HtmlParser
impl UnsafeUnpin for HtmlParser
impl UnwindSafe for HtmlParser
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more