Selenium WebDriverException:无法加载配置文件

时间:2015-04-05 15:28:06

标签: python firefox selenium web-scraping scrapy

我无法弄清楚为什么selenium会抛出这个异常,因为在将它放入while循环和异常处理程序之前,这种结构工作正常。

def parse(self, response):
    phrases = self.get_search_phrases()

    for phrase in phrases:
        while True:
            try:
                proxy = urlparse(self.proxies.pop(0))
                fp = webdriver.FirefoxProfile()
                fp.set_preference("network.proxy.type", 1)
                fp.set_preference("network.proxy.http", proxy.scheme + '://' + proxy.netloc)
                fp.set_preference("network.proxy.http_port", proxy.port)
                fp.update_preferences()
                self.driver = webdriver.Firefox(firefox_profile=fp)
                self.driver.get(BASE_URL)
                input_ = self.driver.find_element_by_id('name')
                button = self.driver.find_element_by_css_selector('#form_person_search button')
                input_.send_keys(phrase)
                button.click()
                sleep(3)
            except (NoSuchElementException, TimeoutException,):
                continue
            else:
                break

0 个答案:

没有答案