當前位置: 首頁>>代碼示例>>Python>>正文


Python firefox_binary.FirefoxBinary方法代碼示例

本文整理匯總了Python中selenium.webdriver.firefox.firefox_binary.FirefoxBinary方法的典型用法代碼示例。如果您正苦於以下問題:Python firefox_binary.FirefoxBinary方法的具體用法?Python firefox_binary.FirefoxBinary怎麽用?Python firefox_binary.FirefoxBinary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.webdriver.firefox.firefox_binary的用法示例。


在下文中一共展示了firefox_binary.FirefoxBinary方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: crawl_setup

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def crawl_setup(tor=False, capture_path="", display_mode=0, port="9000", process_tag="1", exits="US"):
    tor_call = ""
    make_folder(capture_path)
    if tor is True:
        profile_ = setup_profile(tor=True, port=port, firebug=True, netexport=True, noscript=False,
                                 capture_path=capture_path)
        torrc_file = create_tor_config(port, "./torrc-" + process_tag, exits)
        tor_call = start_program("/usr/sbin/tor -f " + torrc_file)
    else:
        profile_ = setup_profile(firebug=True, netexport=True, noscript=False, capture_path=capture_path)
    display_ = Display(visible=0, size=(1024, 768))
    if display_mode == 0:
        display_.start()
    binary = FirefoxBinary("./firefox/firefox")
    driver_ = webdriver.Firefox(firefox_profile=profile_, firefox_binary=binary)
    driver_.set_page_load_timeout(60)
    driver_.set_script_timeout(60)
    return driver_, display_, tor_call 
開發者ID:iclab,項目名稱:centinel,代碼行數:20,代碼來源:foctor_core.py

示例2: __init__

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def __init__(self, *args, **kwargs):
        """Browser management constructor """
        self.current_browser = None
        self.current_window = None
        self.ff_binary_object = FirefoxBinary() 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:7,代碼來源:browser_mgmt.py

示例3: _get_driver

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def _get_driver(self):
        """ Get the web-driver for the scraper. """

        binary = FirefoxBinary('~/bin/geckodriver')
        browser = webdriver.Firefox(firefox_binary=binary)
        driver = webdriver.Firefox()
        driver.implicitly_wait(30)

        return driver 
開發者ID:vanangamudi,項目名稱:newspaper-crawler-scripts,代碼行數:11,代碼來源:googlegroupsscraper.py

示例4: __init__

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def __init__(self):
        os.environ["PATH"] += os.pathsep + GECKODRIVER_BIN
        self.driver = webdriver.Firefox(firefox_binary=FirefoxBinary(FIREFOX_BIN_PATH)) 
開發者ID:eastee,項目名稱:rebreakcaptcha,代碼行數:5,代碼來源:rebreakcaptcha.py

示例5: setUp

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def setUp(self):
        #self.driver = webdriver.Chrome()
        from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
        binary = FirefoxBinary('/gel/usr/yahog/browser/firefox/firefox')
        self.driver = webdriver.Firefox(firefox_binary=binary)
        self.driver.implicitly_wait(30)
        #self.base_url = "http://127.0.0.1:8000/"
        #self.base_url = "http://gif1001-sim.gel.ulaval.ca/?sim=nouveau#tabsmain-simulation"
        self.base_url = "http://gif1001-sim.gel.ulaval.ca/?page=tp&sim=debug#tabsmain-simulation"
        self.verificationErrors = []
        self.accept_next_alert = True 
開發者ID:mgard,項目名稱:epater,代碼行數:13,代碼來源:test.py

示例6: get_webdriver_options

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def get_webdriver_options(cls):
        kwargs = super(FirefoxBase, cls).get_webdriver_options()
        if cls.firefox_binary is not None:
            from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
            kwargs['firefox_binary'] = FirefoxBinary(firefox_path=cls.firefox_binary)
        return kwargs


# Chrome/ChromeDriver don't work on Travis
# https://github.com/travis-ci/travis-ci/issues/272 
開發者ID:django-functest,項目名稱:django-functest,代碼行數:12,代碼來源:base.py

示例7: __init__

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def __init__(self, headless=True, firefox_path=None):
        if headless:
            print("headless mode on")
            self._driver = webdriver.PhantomJS()
        else:
            # credit to https://github.com/SeleniumHQ/selenium/issues/3884#issuecomment-296990844
            binary = FirefoxBinary(firefox_path)
            self._driver = webdriver.Firefox(firefox_binary=binary)

        self._driver.implicitly_wait(10)
        self.data = defaultdict(list) 
開發者ID:tzuhsial,項目名稱:InstagramCrawler,代碼行數:13,代碼來源:instagramcrawler.py

示例8: run

# 需要導入模塊: from selenium.webdriver.firefox import firefox_binary [as 別名]
# 或者: from selenium.webdriver.firefox.firefox_binary import FirefoxBinary [as 別名]
def run(self, input_files, url=None, verbose=0):
        """
        run the headless browser with given input
        if url given, the proc will only run hlb with given url and ignore input_list.
        :param url:
        :param input_files: the name of the file in "index url" format. i.e.
                1, www.facebook.com
                1, www.google.com
                ...
        :param verbose:
        :return:
        """
        if not url and not input_files:
            logging.warning("No input file")
            return {"error": "no inputs"}

        results = {}

        self.open_virtual_display()
        if verbose > 0:
            log_file = sys.stdout
        else:
            log_file = None

        # set up firefox driver 
        self.binary = FirefoxBinary(os.path.join(self.cur_path, 'firefox/firefox'), log_file=log_file)
        self.profile = self.setup_profile()
        self.driver = webdriver.Firefox(firefox_profile=self.profile, firefox_binary=self.binary, timeout=60)
        self.driver.set_page_load_timeout(60)

        isfile = False
        if url:
            host, path = self.divide_url(url)
            results[url] = self.get(host, path)
        else:
            isfile = True
            for input_file in input_files.items():
                logging.info("Testing input file %s..." % (input_file[0]))
                self.run_file(input_file, results)

        # foctor_core will quit the driver by itself so we only quit the driver when we don't use foctor core
        if not isfile:
            logging.info("Quit driver")
            self.driver.quit()
            self.close_virtual_display()

        logging.debug("Deleting har folder")
        shutil.rmtree(os.path.join(self.cur_path, 'har'))
        return results 
開發者ID:iclab,項目名稱:centinel,代碼行數:51,代碼來源:headless_browser.py


注:本文中的selenium.webdriver.firefox.firefox_binary.FirefoxBinary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。