[Python] Get data with Playwright from number of <div> [closed]

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to find an example of using Playwright to scaping data from the web. Data with numerous <div> tags is placed on the webpage. I need to extract it from the tag <span> to array for the tag <product-key-value>. The majority of the code was obtained from here.

    This is one possible code, but it didn't work:

    product_section = page.locator('//div[@class="product-key-value"]')
    spans = product_section.locator('span')
    span_elements = spans.element_handles()

    data_array = [span.text_content() for span in span_elements]
    print(data_array)


    Similar solution, but useless for me:


    This is a screenshot target page

    Continue reading...

Compartilhe esta Página