Skip to main content

data_for_seo/entity/on_page/resource/
html.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use std::collections::HashMap;
4
5/// A crawled HTML page returned by the OnPage Pages endpoint.
6/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
7#[derive(Debug, Serialize, Deserialize, Clone)]
8pub struct OnPageResourceHtml {
9    /// Type of the returned resource (e.g. `html`, `broken`, `redirect`).
10    pub resource_type: Option<String>,
11    /// HTTP status code returned when fetching the page.
12    pub status_code: Option<i32>,
13    /// Location header value indicating the URL the page redirects to.
14    pub location: Option<String>,
15    /// URL of the analyzed page.
16    pub url: Option<String>,
17    /// Meta information extracted from the page.
18    pub meta: Option<OnPageResourceMeta>,
19    /// Page load timing metrics.
20    pub page_timing: Option<OnPageResourceHtmlPageTiming>,
21    /// Overall optimization score on a 100-point scale.
22    pub onpage_score: Option<f64>,
23    /// Total DOM size of the page, in element count.
24    pub total_dom_size: Option<i64>,
25    /// Response of the custom JavaScript executed on the page.
26    pub custom_js_response: Option<Value>,
27    /// Exception thrown by the custom client-side JavaScript, if any.
28    pub custom_js_client_exception: Option<String>,
29    /// True when the page contains broken resources.
30    pub broken_resources: Option<bool>,
31    /// True when the page contains broken links.
32    pub broken_links: Option<bool>,
33    /// True when the page has a duplicate title tag.
34    pub duplicate_title: Option<bool>,
35    /// True when the page has a duplicate meta description.
36    pub duplicate_description: Option<bool>,
37    /// True when the page has duplicate content.
38    pub duplicate_content: Option<bool>,
39    /// Number of clicks required to reach the page from the homepage.
40    pub click_depth: Option<i32>,
41    /// Uncompressed size of the page, in bytes.
42    pub size: Option<i64>,
43    /// Page size after encoding, in bytes.
44    pub encoded_size: Option<i64>,
45    /// Compressed size transferred over the network, in bytes.
46    pub total_transfer_size: Option<i64>,
47    /// Date and time when the resource was fetched (UTC).
48    pub fetch_time: Option<String>,
49    /// Cache-control information for the page.
50    pub cache_control: Option<OnPageResourceHtmlCacheControl>,
51    /// Result of the on-page SEO checks for the page.
52    pub checks: Option<OnPageResourceHtmlWebsiteChecks>,
53    /// Compression algorithm applied to the content.
54    pub content_encoding: Option<String>,
55    /// Media type used to display the page (e.g. `text/html`).
56    pub media_type: Option<String>,
57    /// Server version information from the response headers.
58    pub server: Option<String>,
59    /// True when the item is a single resource.
60    pub is_resource: Option<bool>,
61    /// Last-modified dates from header, sitemap, and meta tag.
62    pub last_modified: Option<OnPageResourceHtmlLastModified>,
63}
64/// Meta information extracted from a crawled HTML page.
65/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
66#[derive(Debug, Serialize, Deserialize, Clone)]
67pub struct OnPageResourceMeta {
68    /// Text of the page title tag.
69    pub title: Option<String>,
70    /// Code page identifier of the page charset (e.g. 65001 for UTF-8).
71    pub charset: Option<i32>,
72    /// True when the meta robots tag allows following links.
73    pub follow: Option<bool>,
74    /// Value of the generator meta tag.
75    pub generator: Option<String>,
76    /// Heading tags on the page keyed by level (h1, h2, …).
77    pub htags: Option<HashMap<String, Option<Vec<String>>>>,
78    /// Content of the meta description tag.
79    pub description: Option<String>,
80    /// URL of the page favicon.
81    pub favicon: Option<String>,
82    /// Content of the meta keywords tag.
83    pub meta_keywords: Option<String>,
84    /// Canonical URL declared for the page.
85    pub canonical: Option<String>,
86    /// Number of internal links on the page.
87    pub internal_links_count: Option<i64>,
88    /// Number of external links on the page.
89    pub external_links_count: Option<i64>,
90    /// Number of images on the page.
91    pub images_count: Option<i64>,
92    /// Total size of images on the page, in bytes.
93    pub images_size: Option<i64>,
94    /// Number of scripts on the page.
95    pub scripts_count: Option<i64>,
96    /// Total size of scripts on the page, in bytes.
97    pub scripts_size: Option<i64>,
98    /// Number of stylesheets on the page.
99    pub stylesheets_count: Option<i64>,
100    /// Total size of stylesheets on the page, in bytes.
101    pub stylesheets_size: Option<i64>,
102    /// Length of the title tag, in characters.
103    pub title_length: Option<i32>,
104    /// Length of the description tag, in characters.
105    pub description_length: Option<i32>,
106    /// Number of scripts that block page rendering.
107    pub render_blocking_scripts_count: Option<i64>,
108    /// Number of stylesheets that block page rendering.
109    pub render_blocking_stylesheets_count: Option<i64>,
110    /// Cumulative Layout Shift, a Core Web Vitals stability metric.
111    pub cumulative_layout_shift: Option<f64>,
112    /// Open Graph and Twitter card social media tags found on the page.
113    pub social_media_tags: Option<Value>,
114    /// Content readability and consistency metrics for the page.
115    pub content: Option<OnPageResourceMetaContent>,
116    /// Deprecated HTML tags found on the page.
117    pub deprecated_tags: Option<Vec<String>>,
118    /// Meta tags that appear more than once on the page.
119    pub duplicate_meta_tags: Option<Vec<String>>,
120    /// Spell-check results for the page content.
121    pub spell: Option<OnPageSpell>,
122    /// Errors and warnings encountered while parsing page resources.
123    pub resource_errors: Option<OnPageResourceErrors>,
124}
125/// Content readability and consistency metrics for a page.
126/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
127#[derive(Debug, Serialize, Deserialize, Clone)]
128pub struct OnPageResourceMetaContent {
129    /// Total size of the plain text on the page, in bytes.
130    pub plain_text_size: Option<i64>,
131    /// Ratio of plain text to total page size.
132    pub plain_text_rate: Option<f64>,
133    /// Number of words on the page.
134    pub plain_text_word_count: Option<i64>,
135    /// Automated Readability Index score.
136    pub automated_readability_index: Option<f64>,
137    /// Coleman–Liau Index readability score.
138    pub coleman_liau_readability_index: Option<f64>,
139    /// Dale–Chall readability score.
140    pub dale_chall_readability_index: Option<f64>,
141    /// Flesch–Kincaid readability score.
142    pub flesch_kincaid_readability_index: Option<f64>,
143    /// SMOG readability score.
144    pub smog_readability_index: Option<f64>,
145    /// Consistency of the meta description with page content (0–1).
146    pub description_to_content_consistency: Option<f64>,
147    /// Consistency of the title tag with page content (0–1).
148    pub title_to_content_consistency: Option<f64>,
149    /// Consistency of the meta keywords with page content (0–1).
150    pub meta_keywords_to_content_consistency: Option<f64>,
151}
152/// Spell-check results for a crawled page.
153/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
154#[derive(Debug, Serialize, Deserialize, Clone)]
155pub struct OnPageSpell {
156    /// Hunspell language code used for spell checking.
157    pub hunspell_language_code: Option<String>,
158    /// Words detected as misspelled on the page.
159    pub misspelled: Option<Vec<OnPageSpellMisspelled>>,
160}
161/// A single misspelled word detected on a page.
162/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
163#[derive(Debug, Serialize, Deserialize, Clone)]
164pub struct OnPageSpellMisspelled {
165    /// The misspelled word.
166    pub word: Option<String>,
167}
168/// Errors and warnings encountered while parsing page resources.
169/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
170#[derive(Debug, Serialize, Deserialize, Clone)]
171pub struct OnPageResourceErrors {
172    /// Errors encountered while parsing the resource.
173    pub errors: Option<Vec<OnPageResourceErrorsError>>,
174    /// Warnings encountered while parsing the resource.
175    pub warnings: Option<Vec<OnPageResourceErrorsWarning>>,
176}
177/// A single error encountered while parsing a page resource.
178/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
179#[derive(Debug, Serialize, Deserialize, Clone)]
180pub struct OnPageResourceErrorsError {
181    /// Line number where the error occurred.
182    pub line: Option<i32>,
183    /// Human-readable error description.
184    pub message: Option<String>,
185}
186/// A single warning encountered while parsing a page resource.
187/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
188#[derive(Debug, Serialize, Deserialize, Clone)]
189pub struct OnPageResourceErrorsWarning {
190    /// Line number where the warning occurred.
191    pub line: Option<i32>,
192    /// Human-readable warning description.
193    pub message: Option<String>,
194}
195/// Page load timing metrics for a crawled page.
196/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
197#[derive(Debug, Serialize, Deserialize, Clone)]
198pub struct OnPageResourceHtmlPageTiming {
199    /// Time to Interactive, in milliseconds.
200    pub time_to_interactive: Option<i64>,
201    /// Time until the page and its subresources finish loading, in milliseconds.
202    pub dom_complete: Option<i64>,
203    /// Largest Contentful Paint, a Core Web Vitals metric, in milliseconds.
204    pub largest_contentful_paint: Option<f64>,
205    /// First Input Delay, a Core Web Vitals responsiveness metric, in milliseconds.
206    pub first_input_delay: Option<f64>,
207    /// Time to connect to the server, in milliseconds.
208    pub connection_time: Option<i64>,
209    /// Time to establish a secure connection, in milliseconds.
210    pub time_to_secure_connection: Option<i64>,
211    /// Time to send the request to the server, in milliseconds.
212    pub request_sent_time: Option<i64>,
213    /// Time to first byte (TTFB), in milliseconds.
214    pub waiting_time: Option<i64>,
215    /// Time for the browser to receive the response, in milliseconds.
216    pub download_time: Option<i64>,
217    /// Total time until the browser receives the complete response, in milliseconds.
218    pub duration_time: Option<i64>,
219    /// Time to start downloading the HTML resource, in milliseconds.
220    pub fetch_start: Option<i64>,
221    /// Time to complete downloading the HTML resource, in milliseconds.
222    pub fetch_end: Option<i64>,
223}
224/// Cache-control information for a crawled page.
225/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
226#[derive(Debug, Serialize, Deserialize, Clone)]
227pub struct OnPageResourceHtmlCacheControl {
228    /// True when the page is cacheable.
229    pub cachable: Option<bool>,
230    /// Time to live the browser caches the resource, in milliseconds.
231    pub ttl: Option<i64>,
232}
233/// Result of the on-page SEO checks for a crawled page.
234/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
235#[derive(Debug, Serialize, Deserialize, Clone)]
236pub struct OnPageResourceHtmlWebsiteChecks {
237    /// True when the page has no content encoding (no compression).
238    pub no_content_encoding: Option<bool>,
239    /// True when the page loading time exceeds 3 seconds.
240    pub high_loading_time: Option<bool>,
241    /// True when the page returns a 3xx redirect status code.
242    pub is_redirect: Option<bool>,
243    /// True when the page returns a 4xx status code.
244    pub is_4xx_code: Option<bool>,
245    /// True when the page returns a 5xx status code.
246    pub is_5xx_code: Option<bool>,
247    /// True when the page is broken (status code below 200 or above 400).
248    pub is_broken: Option<bool>,
249    /// True when the page exists on the www subdomain.
250    pub is_www: Option<bool>,
251    /// True when the page uses the HTTPS protocol.
252    pub is_https: Option<bool>,
253    /// True when the page uses the HTTP protocol.
254    pub is_http: Option<bool>,
255    /// True when the time to first byte exceeds 1.5 seconds.
256    pub high_waiting_time: Option<bool>,
257    /// True when the page has no `<!DOCTYPE>` declaration.
258    pub no_doctype: Option<bool>,
259    /// True when the page is the canonical version.
260    pub canonical: Option<bool>,
261    /// True when the page has no charset encoding meta tag.
262    pub no_encoding_meta_tag: Option<bool>,
263    /// True when the page has empty or absent h1 tags.
264    pub no_h1_tag: Option<bool>,
265    /// True when an HTTPS page links to HTTP pages.
266    pub https_to_http_links: Option<bool>,
267    /// True when the page declares an HTML doctype.
268    pub has_html_doctype: Option<bool>,
269    /// True when the page size is larger than 3 MB.
270    pub size_greater_than_3mb: Option<bool>,
271    /// True when the declared charset and the page charset are consistent.
272    pub meta_charset_consistency: Option<bool>,
273    /// True when the page uses a meta http-equiv refresh redirect.
274    pub has_meta_refresh_redirect: Option<bool>,
275    /// True when the page has render-blocking resources.
276    pub has_render_blocking_resources: Option<bool>,
277    /// True when the page has a chain of at least two redirects.
278    pub redirect_chain: Option<bool>,
279    /// True when the plain-text-to-size ratio is below 0.1.
280    pub low_content_rate: Option<bool>,
281    /// True when the plain-text-to-size ratio is above 0.9.
282    pub high_content_rate: Option<bool>,
283    /// True when the page has fewer than 1024 characters.
284    pub low_character_count: Option<bool>,
285    /// True when the page has more than 256,000 characters.
286    pub high_character_count: Option<bool>,
287    /// True when the page is smaller than 1024 bytes.
288    pub small_page_size: Option<bool>,
289    /// True when the page is larger than 1 MB.
290    pub large_page_size: Option<bool>,
291    /// True when the Flesch–Kincaid readability score is below 15.
292    pub low_readability_rate: Option<bool>,
293    /// True when the meta description is irrelevant to the page content.
294    pub irrelevant_description: Option<bool>,
295    /// True when the title is irrelevant to the page content.
296    pub irrelevant_title: Option<bool>,
297    /// True when the meta keywords are irrelevant to the page content.
298    pub irrelevant_meta_keywords: Option<bool>,
299    /// True when the title exceeds 65 characters.
300    pub title_too_long: Option<bool>,
301    /// True when the title is shorter than 30 characters.
302    pub title_too_short: Option<bool>,
303    /// True when the page contains deprecated HTML tags.
304    pub deprecated_html_tags: Option<bool>,
305    /// True when the page has duplicate meta tags.
306    pub duplicate_meta_tags: Option<bool>,
307    /// True when the page has more than one title tag.
308    pub duplicate_title_tag: Option<bool>,
309    /// True when the page has images without alt attributes.
310    pub no_image_alt: Option<bool>,
311    /// True when the page has images without title attributes.
312    pub no_image_title: Option<bool>,
313    /// True when the page has an empty or absent meta description.
314    pub no_description: Option<bool>,
315    /// True when the page has an empty or absent title tag.
316    pub no_title: Option<bool>,
317    /// True when the page has no favicon.
318    pub no_favicon: Option<bool>,
319    /// True when the URL is SEO-friendly.
320    pub seo_friendly_url: Option<bool>,
321    /// True when the page contains Flash elements.
322    pub flash: Option<bool>,
323    /// True when the page contains frame, iframe, or frameset tags.
324    pub frame: Option<bool>,
325    /// True when the page contains lorem ipsum placeholder text.
326    pub lorem_ipsum: Option<bool>,
327    /// True when the page contains spelling errors.
328    pub has_misspelling: Option<bool>,
329    /// True when the URL contains only Latin characters, digits, and dashes.
330    pub seo_friendly_url_characters_check: Option<bool>,
331    /// True when the URL is free of dynamic parameters.
332    pub seo_friendly_url_dynamic_check: Option<bool>,
333    /// True when the URL is consistent with the title tag.
334    pub seo_friendly_url_keywords_check: Option<bool>,
335    /// True when the URL length is 120 characters or fewer.
336    pub seo_friendly_url_relative_length_check: Option<bool>,
337    /// True when no internal links point to the page (orphan page).
338    pub is_orphan_page: Option<bool>,
339    /// True when the page has both followed and nofollowed incoming internal links.
340    pub is_link_relation_conflict: Option<bool>,
341    /// True when the page links to pages that redirect elsewhere.
342    pub has_links_to_redirects: Option<bool>,
343    /// True when the canonical points to another canonical page (chain).
344    pub canonical_chain: Option<bool>,
345    /// True when the canonical points to a page that redirects elsewhere.
346    pub canonical_to_redirect: Option<bool>,
347    /// True when the canonical points to a broken page.
348    pub canonical_to_broken: Option<bool>,
349    /// True when the page canonicalizes back to itself (recursive canonical).
350    pub recursive_canonical: Option<bool>,
351}
352
353/// Last-modified dates reported for a crawled page.
354/// See <https://docs.dataforseo.com/v3/on_page/pages/>.
355#[derive(Debug, Serialize, Deserialize, Clone)]
356pub struct OnPageResourceHtmlLastModified {
357    /// Last-modified date from the response header (UTC).
358    pub header: Option<String>,
359    /// Last-modified date from the sitemap (UTC).
360    pub sitemap: Option<String>,
361    /// Last-modified date from the page meta tag (UTC).
362    pub meta_tag: Option<String>,
363}