0

我正在使用 scrapy_selenium 运行此代码,但我无法将驱动程序传递给 parse_page,谁能确定我做错了什么?

class LSpider(scrapy.Spider):
    name = 'test'

    def start_requests(self):
        yield SeleniumRequest(
            url='https://www.url.com',
            wait_time=3,
            screenshot=True,
            callback=self.login
        )

    def login(self, response):
        driver = response.request.meta['driver']
        search_input = driver.find_element_by_xpath("(//input[@class='input__input'])[1]")
        search_input.send_keys("user")
        search_input_password = driver.find_element_by_xpath("(//input[@class='input__input'])[2]")
        search_input_password.send_keys("password")
        search_input.send_keys(Keys.ENTER)
        time.sleep(3)

        yield SeleniumRequest(
            url='https:url.com/url',
            callback=self.parse_page,
            screenshot=True
        )

    def parse_page(self, response):
        driver = response.request.meta['driver']
        search = driver.find_element_by_xpath("//input[@class='search-box']")
4

0 回答 0