Сайт загружается после 5 секунд показа текста, но мне нужно получить текстовую форму [ "Loding.."]
по умолчанию установить текст, получить, как подождать, получить правильный текст на сайте, мне нужно добавить код, проверить и проверить, написать ответ
Код: Выделить всё
your textПоказ элементов в течение 5 секунд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
item['SKU'] = sku # Добавить SKU к элементу
description = response.xpath('/ /div[@class="et_pb_text_inner"]//p[@id="description"]/text()').getall()
print("Извлеченное описание:", описание) # Строка отладки
full_description = ' '.join(description).strip()
item['Description'] = full_description # Добавить описание к элементу
Получить правильный текст для сайта п>
Подробнее здесь: https://stackoverflow.com/questions/790 ... loding-why