1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How to Added Wait for Wbe Srapping in Crawl getting text loding.. why?

Discussão em 'Python' iniciado por Stack, Outubro 4, 2024 às 05:32.

  1. Stack

    Stack Membro Participativo

    https://adrianahoyos.com/our-products/living-room/sofa-loveseats/caramelo-tufted-sofa-140/ Site Loading after 5 second show Text but i have to get text form ["Loding.."] by default set text get how to wait get text proper in site i have to aded code bwlow check and verify get to write answer your text

    Before 5 Second Show Elemets

    Loading…
    after 5 second Show Elements

    CM12-140
    def parse_navigation(self, response):
    for level1 in response.xpath('//div[@id="en-menu-products"]//ul/li/a'):
    label1 = level1.xpath('text()').get().strip() # Get the text
    url = level1.xpath('@href').get() # Get the href attribute

    meta = deepcopy(response.meta)
    meta['cat'] = label1
    if label1 in ["Sofa & Loveseats"]:
    yield response.follow(url, self.parse_collection, meta=meta)
    def parse_collection(self, response):
    # Select both links and titles together
    rug_items = response.css('.products .product')
    for rug in rug_items:
    # Extract rug name from the correct element
    name = rug.css('.woocommerce-loop-product__title::text').get(default='').strip()
    meta = deepcopy(response.meta)
    meta['product_name'] = name
    url = rug.css('.woocommerce-LoopProduct-link::attr(href)').get(default='')
    yield Request(url,self.parse_detail, meta=meta, dont_filter=True)

    def parse_detail(self, response):
    time.sleep(5)
    item = OrderedDict()
    item['category'] = response.meta['cat']
    item['name'] = response.meta.get('product_name', '')
    item['Url'] = response.url
    # item['Attr_Collection'] = ''
    sku = response.xpath('//div[@class="et_pb_text_inner"]//p[@id="sku-id"]/text()').get(default='').strip()
    item['SKU'] = sku # Add SKU to item
    description = response.xpath('//div[@class="et_pb_text_inner"]//p[@id="description"]/text()').getall()
    print("Extracted description:", description) # Debugging line
    full_description = ' '.join(description).strip()
    item['Description'] = full_description # Add description to item

    # item['brand'] = 'Adriana Hoyos'
    # item['Original Price'] = ''
    item['MetaKeywords'] = response.css('[name="keywords"]::attr(content)').get('').strip()
    item['MetaDescription'] = response.css('[name="description"]::attr(content)').get('').strip()

    yield item


    issues is below code meanse discription get text from loding item['SKU'] = sku # Add SKU to item description = response.xpath('//div[@class="et_pb_text_inner"]//p[@id="description"]/text()').getall() print("Extracted description:", description) # Debugging line full_description = ' '.join(description).strip() item['Description'] = full_description # Add description to item

    Get proper text for site

    Continue reading...

Compartilhe esta Página