L
L
LordOftheCode2021-09-26 12:14:32
Python
LordOftheCode, 2021-09-26 12:14:32

Xpath python how to take 2 element with similar class?

I want to parse all topics, they are in a row with the same class
. I can only take the first element with

getting_url = parsing_table_urls.find_element_by_xpath("//a[@class='listBlock main PreviewTooltip']")

I looked at other topics, where people took 2 elements with the same class, just add to the end [2] like this:
getting_url = parsing_table_urls.find_element_by_xpath("//a[@class='listBlock main PreviewTooltip'][2]")

I want to go through all the topics like this and add a chila increment together

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-09-26
@LordOftheCode

items = node.find_elements_by_xpath('xpath')
for item in items:
    print(item.get_attribute('href'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question