本文整理汇总了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
示例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()
示例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
示例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))
示例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
示例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
示例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)
示例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