python类ChromeOptions()的实例源码

ChromeFactory.py 文件源码 项目:whatsapp-pybot 作者: iren86 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def build_chrome_options():

        chrome_options = webdriver.ChromeOptions()
        chrome_options.accept_untrusted_certs = True
        chrome_options.assume_untrusted_cert_issuer = True
        # chrome configuration
        # More: https://github.com/SeleniumHQ/docker-selenium/issues/89
        # And: https://github.com/SeleniumHQ/docker-selenium/issues/87
        chrome_options.add_argument("--no-sandbox")
        chrome_options.add_argument("--disable-impl-side-painting")
        chrome_options.add_argument("--disable-setuid-sandbox")
        chrome_options.add_argument("--disable-seccomp-filter-sandbox")
        chrome_options.add_argument("--disable-breakpad")
        chrome_options.add_argument("--disable-client-side-phishing-detection")
        chrome_options.add_argument("--disable-cast")
        chrome_options.add_argument("--disable-cast-streaming-hw-encoding")
        chrome_options.add_argument("--disable-cloud-import")
        chrome_options.add_argument("--disable-popup-blocking")
        chrome_options.add_argument("--ignore-certificate-errors")
        chrome_options.add_argument("--disable-session-crashed-bubble")
        chrome_options.add_argument("--disable-ipv6")
        chrome_options.add_argument("--allow-http-screen-capture")
        chrome_options.add_argument("--start-maximized")

        return chrome_options
LocationCrawler.py 文件源码 项目:InstagramLocationScraper 作者: VoodaGod 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, profilePath, driverPath):
        options = webdriver.ChromeOptions()
        prefs = {"profile.managed_default_content_settings.images":2}
        options.add_argument("user-data-dir=" + profilePath)
        options.add_argument("headless")
        options.add_argument('window-size=1920x1080')
        options.add_experimental_option("prefs", prefs)

        try:
            self.driver = webdriver.Chrome(executable_path=driverPath, chrome_options=options)
        except WebDriverException:
            print("failed to start driver at " + driverPath)
            self.inUse = True #scraper with no driver is not ready to handle new job
            #traceback.print_exc()

        self.inUse = False #if False, is ready to handle new job
        self.bannerClosed = False #email banner only needs to be closed on first load
        self.timeLimit  = datetime.now() + timedelta(minutes=TIMEOUT_MINUTES)
kickerrankade.py 文件源码 项目:foosball 作者: kangkai 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, username, passwd, playground, groupname):
        self.playground = playground

        chrome_options = webdriver.ChromeOptions()
        #chrome_options.add_argument('--start-maximized')
        chrome_options.add_argument('--proxy-server=http://xx.mioffice.cn:8888')
        self.driver = webdriver.Chrome(chrome_options = chrome_options)
        driver = self.driver

        driver.implicitly_wait(300) # seconds
        driver.get('https://rankade.com/')
        assert 'rankade' in driver.title

        driver.find_element_by_css_selector("a.sign-button.sign-in-button").click()
        assert 'Sign in' in driver.title

        input = driver.find_element_by_name("email")
        input.send_keys(username)
        input = driver.find_element_by_name("password")
        input.send_keys(passwd)
        driver.find_element_by_name("submit").click()
        assert 'rankade' in driver.title
        driver.find_element_by_id("dashboardLink").click()
        # assert 'rankade - My dashboard' in driver.title
        driver.find_element_by_link_text(groupname).click()
test.py 文件源码 项目:readwx 作者: xocom 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def gethtml(zurl,str_fname):
    mobileEmulation = {'deviceName': 'Apple iPhone 6'}
    options = webdriver.ChromeOptions()
    options.add_experimental_option('mobileEmulation', mobileEmulation)
    driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)


    driver.get(zurl)
    time.sleep(5)
    result = []


    # for i in range(0,300):  #???0?20?????i?
    for i in range(0, 1):  # ???0?3?????i?
        print('????' + str(i))
        myscroll(driver)
        time.sleep(2)

    st=time.strftime("%Y%m%d",time.localtime())
    # print(driver.page_source, file=open('itg201703.html', 'w', encoding='utf-8'))
    print(driver.page_source, file=open(str_fname+"-"+st+".html", 'w', encoding='utf-8'))
    print("?????????")
    print(driver.title)
    driver.quit()
automation.py 文件源码 项目:insta-liker 作者: mohdomama 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def setup():

    global browser
    driverPath = os.getcwd()+'/chromedriver'
    url = r'https://www.instagram.com/accounts/login/'
    chromeOptions = webdriver.ChromeOptions()
    #chromeOptions.binary_location='/opt/google/chrome/google-chrome'

    '''                                             #These arguments make chrome run headless.Unfortunately the chrome headless is in beta and hence considerably slow.
    chromeOptions.add_argument("--headless")            
    chromeOptions.add_argument("--disable-gpu")
    chromeOptions.add_argument("--start-fullscreen")
    '''

    prefs = {"profile.managed_default_content_settings.images":2}
    chromeOptions.add_experimental_option("prefs",prefs)
    print('reached 1')
    browser = webdriver.Chrome(driverPath,chrome_options=chromeOptions)
    print('reached')
    #browser.set_window_position(-10000000, 0)       #move chrome away from view
    print('Fetching login page..')
    browser.get(url)
    print('reached login page')
fanc.py 文件源码 项目:bilibili-selenium-project 作者: umiharasorano 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def strat_isml(thread):
    uaList = []
    for line in open('Base_Data\\ualist.txt'):
        uaList.append(line[:-1])
    open('Base_Data\\ualist.txt').close()
    i = random.choice(uaList)
    option = webdriver.ChromeOptions()
    option.add_argument('--user-agent={}'.format(i))
    option.add_argument('--profile-directory=Default')
    option.add_argument('--user-data-dir=c:\\Users\\{}'.format(thread))
    with open("Base_Data\\ChromeOptions.txt") as a:
        for line in a:
            option.add_argument(line)
    path1 = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe'
    path2 = 'C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe'
    try:
        dr = webdriver.Chrome(path1,chrome_options=option)
    except:
        dr = webdriver.Chrome(path2,chrome_options=option)
    return dr,uaList
selenium_usage.py 文件源码 项目:base_function 作者: Rockyzsu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def netease():
    options = webdriver.ChromeOptions()
    options.add_argument(
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36')
    driver = webdriver.Chrome(executable_path=r'C:\software\chrome\chromedriver.exe',
                              chrome_options=options)
    driver.implicitly_wait(40)
    driver.get("http://30daydo.com/")
    elem_user = driver.find_element_by_tag_name("??")
    elem_user.click()
    ''''
    elem_pwd = driver.find_element_by_name("password")
    elem_pwd.send_keys("123456")
    elem_pwd.send_keys(Keys.RETURN)
    '''
    time.sleep(5)
    assert "baidu" in driver.title
    driver.close()
    driver.quit()
selenium_usage.py 文件源码 项目:base_function 作者: Rockyzsu 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def key_operation():
    # ????
    options = webdriver.ChromeOptions()
    options.add_argument(
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36')
    browser = webdriver.Chrome(executable_path=r'C:\software\chrome\chromedriver.exe',
                               chrome_options=options)  #
    browser.implicitly_wait(60)

    browser.get('https://m.fang.com/fangjia/sz_list_pinggu/')
    #browser.send_keys(Keys.DOWN)
    count=0
    while count<190:

        browser.find_element_by_xpath("//body[@class='whitebg']").send_keys(Keys.PAGE_DOWN)
        time.sleep(5)
        count=count+1
    raw_input('enter')
AresSnapshots.py 文件源码 项目:python-ares 作者: pynog 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def takeSnapshot(report_name, root_path, script_name=None, *args, **kwargs):
  """ """

  options = webdriver.ChromeOptions()
  options.add_argument("headless")
  driver = webdriver.Chrome(os.path.join(root_path, 'system', 'webDrivers', 'chromedriver'), chrome_options=options)
  if not script_name:
    script_name = report_name

  url_str = url_for('ares.run_report', report_name=report_name, script_name=script_name, **kwargs)
  if report_name.startswith('_'):
    report_dir = os.path.join(root_path, config.ARES_FOLDER, 'reports', report_name)
    if report_name == '_AresTemplates':
      url_str = url_for('ares.run_template', template=script_name)
  else:
    report_dir = os.path.join(root_path, config.ARES_USERS_LOCATION, report_name)
  driver.get(url_str)
  driver.save_screenshot(os.path.join(report_dir, '%s.png' % script_name ))
  driver.quit()
capabilities.py 文件源码 项目:nerodia 作者: watir 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _process_chrome_options(self, opts):
        if isinstance(opts, ChromeOptions):
            options = opts
        else:
            options = ChromeOptions()
            if 'args' in opts:
                for arg in opts.pop('args'):
                    options.add_argument(arg)
            if 'headless' in opts:
                options.set_headless()
            if 'binary' in opts or 'binary_location' in opts:
                options.binary_location = opts.pop('binary') or opts.pop('binary_location')
            if 'debugger_address' in opts:
                options.debugger_address = opts.pop('debugger_address')
            if 'extensions' in opts:
                for path in opts.pop('extensions'):
                    options.add_extension(path)
            if 'encoded_extensions' in opts:
                for string in opts.pop('encoded_extensions'):
                    options.add_encoded_extension(string)
            if 'experimental_options' in opts:
                for name, value in opts.pop('experimental_options').items():
                    options.add_experimental_option(name, value)
        self.selenium_opts['options'] = options
_functions.py 文件源码 项目:pytoto 作者: mtrpires 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def brInit(adb_crx=None):
    """
    Initialises Selenium's webdriver (Chrome)
    This version uses an adblock extension to load pages faster.
    Download the crx file and save it in the same folder.
    You can use any extension you want.

    return: webdriver object
    """
    if adb_crx == None:
        driver = driver = webdriver.Chrome()
    else:
        chop = webdriver.ChromeOptions()
        chop.add_extension(adb_crx)
        driver = webdriver.Chrome(chrome_options = chop)
    return driver
html_downloader.py 文件源码 项目:wechat_spider 作者: CoolWell 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test():
    profile_dir = r"D:\MyChrome\Default"
    # ?????
    # "Referer": "http://weixin.sogou.com"
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--user-data-dir=" + os.path.abspath(profile_dir))
    PROXY = "123.56.238.200:8123"
    # j = random.randint(0, len(proxys)-1)
    # proxy = proxys[j]
    chrome_options.add_argument('--proxy-server=%s' % PROXY)
    # chrome_options.add_extension('')??crx??
    # service_args = ['--proxy=localhost:9050', '--proxy-type=socks5', ]
    driver = webdriver.Chrome(r'C:\Python27\chromedriver', chrome_options=chrome_options)
    driver.get('http://icanhazip.com')
    driver.refresh()
    print(driver.page_source)
    driver.quit()
proximus_auto_add_vol_pack.py 文件源码 项目:proximus_auto_add_vol_pack 作者: salcin 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, user, pwd, repeat, debug):
        self.debug = debug
        self.set_debug()        # if self.debug = yes view procedure step by step in the browser

        # don't loading the images to optimize the speed of requests
        chromeOptions = webdriver.ChromeOptions()
        prefs = {"profile.managed_default_content_settings.images":2}
        chromeOptions.add_experimental_option("prefs",prefs)

        self.browser = webdriver.Chrome(chrome_options=chromeOptions)
        self.login(user, pwd)

        self.go_to_internet()

        i = 1
        while i <= repeat:
            i += 1
            self.go_to_service()
            self.confirmed()

        self.logout()
browser_automation.py 文件源码 项目:sportsball 作者: jgershen 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_browser(sport, debug=False):
  """
  Use selenium and chromedriver to do our website getting.
  Might as well go all the way.
  :param debug: whether to set the browser to debug mode
  :param headless: go headless
  :return:
  """
  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_argument('--user-agent=%s' % USERAGENT)
  webdriver.DesiredCapabilities.CHROME["userAgent"] = "ignore"
  prefs = {"download.default_directory" : root_data_dir.format(sport=sport)}
  chrome_options.add_experimental_option("prefs",prefs)
  browser = webdriver.Chrome(chrome_options=chrome_options)
  browser.implicitly_wait(10)  # wait up to 10s for an element if it's not instantly available
  return browser
BlogHitsRobot.py 文件源码 项目:AutoTestFramework 作者: huilansame 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def flush(browser, n):
    ua = DesiredCapabilities().IPHONE
    for i in range(n):
        if browser.lower() == 'firefox':
            driver = webdriver.Firefox()
        elif browser.lower() == 'chrome':
            options = webdriver.ChromeOptions()
            options.add_argument('--disable-extensions')
            driver = webdriver.Chrome(executable_path=driver_path + 'chromedriver.exe', chrome_options=options)
        elif browser.lower() == 'ie':
            driver = webdriver.Ie(executable_path=driver_path + 'IEDriverServer.exe')
        elif browser.lower() == 'phantomjs':
            killphantomjs()
            driver = webdriver.PhantomJS(executable_path=driver_path + 'phantomjs.exe', desired_capabilities=ua)
        driver.get('http://m.baidu.com')
        driver.find_element_by_id('index-kw').send_keys(random.choice(KEYWORDS), Keys.ENTER)
        clk(driver, url='csdn')
        sleep(1)
        print driver.find_element_by_class_name('article_t').text,
        print driver.find_element_by_xpath('//p[@class="date"]/i[2]').text
        driver.close()
crawler.py 文件源码 项目:SiteScan 作者: jasonsheh 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, target, dynamic=0):
        self.target = target
        self.dynamic = dynamic
        self.url_set = []  # ??????
        self.urls = []  # ?????????
        self.sitemap = []
        self.q = queue.Queue(0)
        self.url_rule = []
        self.thread_num = 4
        self.header = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}

        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_argument("--headless")
        self.chrome_options.add_argument("--disable-gpu")
        self.chrome_options.add_argument("--window-size=1920x1080")
        self.chrome_options.add_argument("--disable-xss-auditor")
        # ????
        chrome_prefs = {}
        chrome_prefs["profile.default_content_settings"] = {"images": 2}
        self.chrome_options.experimental_options["prefs"] = chrome_prefs
xss.py 文件源码 项目:SiteScan 作者: jasonsheh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, targets):
        self.targets = targets
        self.target = ''

        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_argument("--headless")
        self.chrome_options.add_argument("--disable-gpu")
        self.chrome_options.add_argument("--window-size=1920x1080")
        self.chrome_options.add_argument("--disable-xss-auditor")
        # ????
        chrome_prefs = {}
        chrome_prefs["profile.default_content_settings"] = {"images": 2}
        self.chrome_options.experimental_options["prefs"] = chrome_prefs

        self.header = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
        self.payloads = ['\'"/><img src=# onerror=alert(1);>',
                         "\'\"><body onload=alert(1)>",
                         "/></script><ScRiPt>alert(1);<ScRiPt><!--"]
test_console_log.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
test_events.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
test_attributes.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
test_scrolling.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
        self.page.browser.set_window_size(800, 600)
test_ng.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
test_wait.py 文件源码 项目:pyselenium-js 作者: neetjn 项目源码 文件源码 阅读 103 收藏 0 点赞 0 评论 0
def setUp(self):
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        self.page = MyPage(browser=webdriver.Chrome(chrome_options=chrome_options))
        self.page.browser.get('http://localhost:3000')
selenium.py 文件源码 项目:SerpScrap 作者: ecoron 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _get_Chrome(self):
        try:
            chrome_ops = webdriver.ChromeOptions()
            if self.proxy:
                chrome_ops = webdriver.ChromeOptions()
                chrome_ops.add_argument(
                    '--proxy-server={}://{}:{}'.format(
                        self.proxy.proto,
                        self.proxy.host,
                        self.proxy.port
                    )
                )
                self.webdriver = webdriver.Chrome(
                    executable_path=self.config['executable_path'],
                    chrome_options=chrome_ops
                )

            chrome_ops.add_argument('--no-sandbox')
            chrome_ops.add_argument('--start-maximized')
            chrome_ops.add_argument(
                '--window-position={},{}'.format(
                    randint(10, 30),
                    randint(10, 30)
                )
            )
            chrome_ops.add_argument(
                '--window-size={},{}'.format(
                    randint(800, 1024),
                    randint(600, 900)
                )
            )
            self.webdriver = webdriver.Chrome(
                executable_path=self.config['executable_path'],
                chrome_options=chrome_ops
            )
            return True
        except WebDriverException:
            raise
        return False
download.py 文件源码 项目:audible-downloader 作者: Kagee 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def configure_browser(options):
    logging.info("Configuring browser")


    opts = webdriver.ChromeOptions()

    # Chrome user agent will download files for us
    #opts.add_argument("user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36")

    # This user agent will give us files w. download info
    opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko")
    chromePrefs = {
        "profile.default_content_settings.popups":"0", 
        "download.default_directory":options.dw_dir}
    opts.add_experimental_option("prefs", chromePrefs)

    if sys.platform == 'win32':
        chromedriver_path = "chromedriver.exe"
    else:
        chromedriver_path = "./chromedriver"

    logging.info("Starting browser")

    driver = webdriver.Chrome(chrome_options=opts,
                              executable_path=chromedriver_path)

    return driver
web_funcs.py 文件源码 项目:integration 作者: mendersoftware 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def chrome_driver():
    options = webdriver.ChromeOptions()
    options.add_argument('--ignore-certificate-errors')

    return webdriver.Chrome(chrome_options=options)
spider.py 文件源码 项目:OS_FrontendMaster-dl 作者: li-xinyang 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, mute_audio):
        options = webdriver.ChromeOptions()

        # FM detects useragent and says 403 as return
        # so we just define valid useragent
        options.add_argument("--user-agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'")
        options.add_argument("--headless")
        options.add_argument("--disable-gpu")
        options.add_argument("--window-size=1920x1080")

        if mute_audio:
            options.add_argument("--mute-audio")

        self.browser = webdriver.Chrome(chrome_options=options)
ReserveProcessor.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def runDelete(self):
        self.statusBarSignal.emit("Lösche Reservierungen...")
        options = webdriver.ChromeOptions()
        if self.settings.value('chrome/headless', True, bool):
            options.add_argument('--headless')

        try:
            self.driver = Remote('http://localhost:9515', desired_capabilities=options.to_capabilities())
        except Exception as e:
            QtWidgets.QMessageBox.critical(self, QtWidgets.qApp.tr("Keine Verbindung zu Google Chrome!"),
                                           QtWidgets.qApp.tr(
                                               "Es konnte keine Verbindung zu Google Chrome hergestellt werden! "
                                               "Bitte stelle sicher, dass alle Systemvoraussetzungen erfüllt sind.\n\n"
                                               "Fehler:\n" + str(e)),
                                           QtWidgets.QMessageBox.Cancel)
            return

        self.driver.get(self.baseUrl)

        for cookie in self.cookies:
            self.driver.add_cookie(cookie)

        for match in self.selected:
            match = self.insertMafoId(match)
            self.delete(match)
            self.markRowAsReserved(match, 0)

        self.loggerSignal.emit('%s Reservierungen erfolgreich gelöscht.' % len(self.selected) )

        self.driver.close()
GaleryProcessor.py 文件源码 项目:FuME 作者: fupadev 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def run(self):
        self.loggerSignal.emit("Initialisiere Browser...")
        options = webdriver.ChromeOptions()
        if self.settings.value('chrome/headless', True, bool):
            options.add_argument('--headless')

        try:
            self.driver = Remote('http://localhost:9515', desired_capabilities=options.to_capabilities())
        except Exception as e:
            QtWidgets.QMessageBox.critical(self, QtWidgets.qApp.tr("Keine Verbindung zu Google Chrome!"),
                                           QtWidgets.qApp.tr(
                                               "Es konnte keine Verbindung zu Google Chrome hergestellt werden! "
                                               "Bitte stelle sicher, dass alle Systemvoraussetzungen erfüllt sind.\n\n"
                                               "Fehler:\n" + str(e)),
                                           QtWidgets.QMessageBox.Cancel)
            return

        self.driver.get(self.baseUrl)

        for cookie in self.cookies:
            self.driver.add_cookie(cookie)

        self.createGalery()

        self.loggerSignal.emit('Galerie erfolgreich erstellt.')

        self.driver.close()
base.py 文件源码 项目:wdom 作者: miyakogi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_chrome_options() -> webdriver.ChromeOptions:
    """Get default chrome options."""
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')  # need for headless
    if 'TRAVIS'in os.environ:
        chrome_options.add_argument('--no-sandbox')
    return chrome_options


问题


面经


文章

微信
公众号

扫码关注公众号