Skip to content

Instantly share code, notes, and snippets.

@Ze1598
Created July 28, 2021 18:45
Show Gist options
  • Select an option

  • Save Ze1598/64d87b669e178f64c5f5e44c6364427f to your computer and use it in GitHub Desktop.

Select an option

Save Ze1598/64d87b669e178f64c5f5e44c6364427f to your computer and use it in GitHub Desktop.

Revisions

  1. Ze1598 created this gist Jul 28, 2021.
    64 changes: 64 additions & 0 deletions read_level_stats.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    # imports, driver variable set up and loading a character page
    # (...)

    # First thing we need before reading data: decrease the operator level (even if it is already at the lowest level possible)
    # Otherwise some stats may be missing
    decrease_level_button = driver.find_element_by_class_name("fa-arrow-left")
    decrease_level_button.click()

    # Read the opreator class
    operator_class = driver.find_element_by_class_name("profession-title").text.strip()
    # Read the operator rarity by counting the number of stars in their rarity
    operator_rarity = len(
    driver
    .find_element_by_class_name("rarity-cell")
    .find_elements_by_tag_name("img")
    )

    # HTML tables with info on operator release date and availability
    obtain_approach_tables = driver\
    .find_element_by_class_name("obtain-approach-table")\
    .find_elements_by_tag_name("table")

    # Get the release date in the chinese server
    cn_release_date = obtain_approach_tables[1]\
    .find_elements_by_tag_name("tr")[0]\
    .find_element_by_tag_name("td")\
    .text
    # Get the release date in the global server
    global_release_date = obtain_approach_tables[1]\
    .find_elements_by_tag_name("tr")[1]\
    .find_element_by_tag_name("td")\
    .text
    # Text with headhunting availability status
    headhunting_type = obtain_approach_tables[0]\
    .find_elements_by_tag_name("tr")[0]\
    .find_element_by_tag_name("td")\
    .text
    # If the text has the word limited, then the unit is limited
    operator_is_limited = True if "limited" in headhunting_type.lower() else False

    # Current elite level
    # Of the three promotion level buttons/levels, find the one selected
    promotion_level_selected_elem = driver.find_element_by_class_name("current-button")
    # Non-Elite means 0, otheriwse take the last character of the level name (1 or 2)
    promotion_level = "0" if promotion_level_selected_elem.text == "Non-Elite" else promotion_level_selected_elem.text[-1]

    # Current operator level
    operator_level = driver.find_element_by_id("myRange").get_attribute('value')

    # Hp, Atk, Def
    stats_container_elem = driver.find_element_by_id("stats-container")
    # This reads a single string of stat names and values
    # Split the stat names and values into a list (split at newlines)
    stats_split = stats_container_elem.text.splitlines()
    # Get the individual stat values
    op_hp, op_atk, op_def = stats_split[1], stats_split[3], stats_split[5]

    # Other stats
    other_stats_container_elem = driver.find_element_by_class_name("other-stat-cell")
    # Same logic as before
    # Split the stat names and values into a list (split at newlines)
    other_stats_split = other_stats_container_elem.text.splitlines()
    # Get the individual stat values
    op_res, op_redeploy, op_cost, op_block, op_atk_interv = other_stats_split[1], other_stats_split[3], other_stats_split[5], other_stats_split[7], other_stats_split[9]