[Python] scrapy with css selector : no result

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I need to retrieve information from our website but I can't get results with Scrapy. At this stage of the project, I need to retrieve the training labels (for example: Validation of acquired experience)

    the url of the site : https://monavenirpro-hdf.fr/formations/

    <div class="elementor-widget-wrap elementor-element-populated" xpath="1">
    <div class="elementor-element elementor-element-33fed426 elementor-widget__width-auto elementor-widget elementor-widget-heading" data-id="33fed426" data-element_type="widget" data-widget_type="heading.default">
    <div class="elementor-widget-container">
    <span class="elementor-heading-title elementor-size-default">Accompagnement</span> </div>
    </div>
    <div class="elementor-element elementor-element-49bd7747 elementor-widget__width-auto elementor-widget elementor-widget-heading" data-id="49bd7747" data-element_type="widget" data-widget_type="heading.default">
    <div class="elementor-widget-container">
    <span class="elementor-heading-title elementor-size-default" style="">Validation des Acquis de l'Expérience - Livret 2</span> </div>
    </div>
    </div>


    I would like to retrieve the informations in the span :

    Accompagnement
    Validation des Acquis de l'Expérience - Livret 2


    Could you help me ?

    Thanks a lot

    Voici mon code :

    import scrapy

    class monavenirpro(scrapy.Spider):
    name : "monavenirpro"
    start_urls = [""https://monavenirpro-hdf.fr/formations/"]

    def parse(self, response):

    libelles = response.css("div[class='elementor elementor-44463 dce-elementor-rendering-id-1'] div["
    "class='elementor-element elementor-element-49bd7747"
    "elementor-widget__width-auto elementor-widget elementor-widget-heading'] span["
    "class='elementor-heading-title elementor-size-default']::text").extract()
    yield {"listlibelles": libelles}


    the terminal returns:

    {'listlibelles': []}

    Continue reading...

Compartilhe esta Página