Function extract_runes

Source
fn extract_runes(first_table: Node<'_>, second_table: Node<'_>) -> RunesData
Expand description

⚙️ Function: Extracts rune data from two HTML tables.

This function processes two HTML tables (representing primary and secondary runes) and extracts the rune images by filtering out those that are not visible (with opacity: 0.2) and by cleaning the alt attributes of the remaining images. The function then constructs a RunesData struct containing all rune data if exactly 9 runes are found.

§Parameters:

  • first_table: A select::node::Node representing the primary rune table.
  • second_table: A select::node::Node representing the secondary rune table.

§Returns:

  • RunesData: Returns a RunesData struct containing the extracted rune information. If the number of runes found is not exactly 9, it returns a RunesData struct with empty strings for all fields.

§Example:

This function is typically called to process rune tables extracted from a web page:

let runes_data = extract_runes(primary_table, secondary_table);
println!("{:?}", runes_data);

§Notes:

  • The function first collects all img tags from both the primary and secondary rune tables.
  • It filters out images that have a parent div with opacity: 0.2 and skips any image without a valid alt attribute.
  • The clean_alt_text function is applied to clean up the alt text before it is added to the final rune list.
  • The function expects exactly 9 runes: 4 primary runes, 2 secondary runes, and 3 tertiary runes. If this condition is not met, an empty RunesData struct is returned.