0

我正在尝试单击 Tripadvisor 提供的每个邮轮列表的附加信息。之后,我想在单击框后获取价格信息并生成该信息。

但是,我收到以下错误:

消息:元素点击被拦截:元素 ... 在点 (478, 594) 处不可点击。其他元素会收到点击:...

这是我尝试过的:

import scrapy
from scrapy_selenium import SeleniumRequest
import time
from scrapy.selector import Selector 

class CruisesSpider(scrapy.Spider):
    name = 'cruises'
    start_urls = ['https://www.tripadvisor.co.uk/Cruises-g4-Europe-Cruises']

    def start_requests(self):
        for url in self.start_urls:
            yield SeleniumRequest(
                url=url, 
                callback = self.parse
            )

    def parse(self, response):
        driver = response.request.meta['driver']
        box_click=driver.find_elements_by_xpath("(.//div[@class='bQumY b _S']//*[name()='svg'][@class='bDFSd d Vb ymbyq'])")
        for boxes in box_click:
            boxes.click()
            time.sleep(1)
            html = driver.page_source
            resp = Selector(text=html)
            yield {
                    'price': resp.xpath('(.//div[@class="gaweO"]//span)[position() mod 2=1]/text()').get()
                }

4

0 回答 0