To import Python selenium child element text

Asked 2 years ago, Updated 2 years ago, 93 views

There is a class with the class name list-item.tier-01.champ-item (green) Kids with 1 tier are list-item.tier-01...I Children with two tiers are listed-item.tier-02...It looks like this.

I want to bring up the text of the element whose tag is p among the classes with 1 tier How do I do it?

Ex) > Darius
          Fiora
          Jays

The current element value is loaded, but it cannot be converted to text.

champ_tier = driver.find_elements(By.CLASS_NAME, 'list-item.tier-01.champ-item')
champ_names = []
for i in champ_tier:
    champ_name = i.find_elements(By.TAG_NAME, 'p')
    champ_names.append(champ_name)

print(champ_names)

python selenium web-crawling

2022-09-20 08:42

1 Answers

This is usually how it should be.

champ_names.append(champ_name.text)


2022-09-20 08:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.