Python selenium.webdriver 模块,ChromeOptions() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用selenium.webdriver.ChromeOptions()

项目:whatsapp-pybot    作者:iren86    | 项目源码 | 文件源码
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
项目:InstagramLocationScraper    作者:VoodaGod    | 项目源码 | 文件源码
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)
项目:foosball    作者:kangkai    | 项目源码 | 文件源码
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()
项目:readwx    作者:xocom    | 项目源码 | 文件源码
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()
项目:insta-liker    作者:mohdomama    | 项目源码 | 文件源码
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')
项目:bilibili-selenium-project    作者:umiharasorano    | 项目源码 | 文件源码
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
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
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()
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
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')
项目:python-ares    作者:pynog    | 项目源码 | 文件源码
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()
项目:nerodia    作者:watir    | 项目源码 | 文件源码
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
项目:pytoto    作者:mtrpires    | 项目源码 | 文件源码
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
项目:wechat_spider    作者:CoolWell    | 项目源码 | 文件源码
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    作者:salcin    | 项目源码 | 文件源码
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()
项目:sportsball    作者:jgershen    | 项目源码 | 文件源码
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
项目:AutoTestFramework    作者:huilansame    | 项目源码 | 文件源码
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()
项目:SiteScan    作者:jasonsheh    | 项目源码 | 文件源码
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
项目:SiteScan    作者:jasonsheh    | 项目源码 | 文件源码
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><!--"]
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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')
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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')
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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')
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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)
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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')
项目:pyselenium-js    作者:neetjn    | 项目源码 | 文件源码
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')
项目:SerpScrap    作者:ecoron    | 项目源码 | 文件源码
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
项目:audible-downloader    作者:Kagee    | 项目源码 | 文件源码
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
项目:integration    作者:mendersoftware    | 项目源码 | 文件源码
def chrome_driver():
    options = webdriver.ChromeOptions()
    options.add_argument('--ignore-certificate-errors')

    return webdriver.Chrome(chrome_options=options)
项目:OS_FrontendMaster-dl    作者:li-xinyang    | 项目源码 | 文件源码
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)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
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()
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
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()
项目:wdom    作者:miyakogi    | 项目源码 | 文件源码
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
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def anjuke():
    client=pymongo.MongoClient('127.0.0.1',27017)
    db=client['test']
    collection=db['anjuke_selenium']
    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')
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    browser = webdriver.Chrome(executable_path=r'C:\software\chrome\chromedriver.exe',
                               chrome_options=options)
    browser.implicitly_wait(30)
    for i in range(1,101):
        browser = webdriver.Chrome(executable_path=r'C:\software\chrome\chromedriver.exe',
                                   chrome_options=options)
        browser.get('https://shenzhen.anjuke.com/community/p%d/' %i)
        l = browser.find_elements_by_xpath('//div[@_soj="xqlb"]')
        print len(l)
        for i in l:
            item = dict()
            item['name']=i.find_element_by_xpath('.//div[@class="li-info"]/h3/a').text
            item['url']=i.find_element_by_xpath('.//div[@class="li-info"]/h3/a').get_attribute('href')
            item['location']=i.find_element_by_xpath('.//div[@class="li-info"]/address').text
            item['building_date']=i.find_element_by_xpath('.//div[@class="li-info"]/p').text
            item['price']= i.find_element_by_xpath('.//div[@class="li-side"]/p/strong').text
            #print item
            collection.insert(item)
        browser.close()
项目:base_function    作者:Rockyzsu    | 项目源码 | 文件源码
def template():
    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)
项目:bowtie    作者:jwkvam    | 项目源码 | 文件源码
def chrome_driver():
    """Set up chrome driver."""
    options = webdriver.ChromeOptions()
    if platform == 'darwin':
        options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
    else:
        options.binary_location = '/usr/bin/google-chrome-stable'
    options.add_argument('headless')
    options.add_argument('window-size=1200x800')
    driver = webdriver.Chrome(chrome_options=options)
    yield driver
    driver.quit()
项目:wagtail-startproject    作者:leukeleu    | 项目源码 | 文件源码
def get_driver(cls):
        """Setup a Chrome webdriver"""

        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        cls.set_driver_options(options)
        try:
            driver = webdriver.Chrome('./node_modules/.bin/chromedriver', chrome_options=options)
        except WebDriverException:
            raise unittest.SkipTest('Not able to start Chrome driver.')
        return driver
项目:dispatch-console-tests    作者:jdanekrh    | 项目源码 | 文件源码
def initialize_local_chrome():
    options = webdriver.ChromeOptions()
    options.binary_location = '/home/jdanek/.nix-profile/bin/google-chrome-stable'
    driver = webdriver.Chrome(chrome_options=options)
    return driver
项目:Kad    作者:liuzhuocpp    | 项目源码 | 文件源码
def getChromeBrowser():
    myProxy= 'proxy.abuyun.com:9020'
    option = webdriver.ChromeOptions()
    option.add_argument('--user-data-dir=C:\Users\LZ\AppData\Local\Google\Chrome\User Data\Default') #????????????
    option.add_argument('--proxy-server=%s' % myProxy)
    browser = webdriver.Chrome(executable_path="chromedriver", chrome_options=option)
    return browser
项目:pythoner    作者:jsRuner    | 项目源码 | 文件源码
def openBrower():
    print("?????...")

    # driver = webdriver.Firefox()
    # driver = webdriver.Ie()
    options = webdriver.ChromeOptions()
    options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
    driver = webdriver.Chrome(chrome_options=options)

    # driver = webdriver.Chrome()
    return driver
项目:selenium-toy    作者:blackmatrix7    | 项目源码 | 文件源码
def __init__(self):
        # ??????
        options = webdriver.ChromeOptions()
        prefs = {"profile.managed_default_content_settings.images": 2}
        options.add_experimental_option("prefs", prefs)
        if platform.system() == 'Darwin':
            executable_path = '{0}/{1}'.format(current_config.PROJ_PATH, 'chromedriver')
        else:
            executable_path = 'chromedriver.exe'
        self.driver = webdriver.Chrome(executable_path=executable_path, chrome_options=options)
        self.driver.implicitly_wait(current_config['TIME_OUT'])
        self.driver.set_window_size(1440, 900)
项目:python-web-pdb    作者:romanvm    | 项目源码 | 文件源码
def setUpClass(cls):
        if sys.platform == 'win32':
            cls.browser = webdriver.Firefox()
        else:
            options = webdriver.ChromeOptions()
            options.add_argument('headless')
            options.add_argument('disable-gpu')
            cls.browser = webdriver.Chrome(chrome_options=options)
        cls.browser.get('http://127.0.0.1:5555')
        cls.stdin = cls.browser.find_element_by_id('stdin')
        cls.send_btn = cls.browser.find_element_by_id('send_btn')
项目:weiboCrawler    作者:hjydzh    | 项目源码 | 文件源码
def get_chrome():
    profile_dir=r"C:\Users\junyu\AppData\Local\Google\Chrome\User Data"
    options = webdriver.ChromeOptions()
    #options.add_argument("user-data-dir="+os.path.abspath(profile_dir))
    options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
    return webdriver.Chrome('G:/lessUsedTools/browser/chrome/chromedriver.exe',chrome_options=options)
项目:wechat_spider    作者:CoolWell    | 项目源码 | 文件源码
def download_articles_chrome(self, url):
        # service_args = ['--load-images=no', ]
        profile_dir = r"D:\MyChrome\Default"
        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', '--load-images=no', ]
        try:
            driver = webdriver.Chrome(r'C:\Python27\chromedriver', chrome_options=chrome_options)
        except Exception as e:
            print(datetime.datetime.now())
            print(url)
            print(e)
        else:

            try:
                driver.set_page_load_timeout(30)
                driver.get(url)
                driver.implicitly_wait(2)
                html = driver.page_source
                return html
            except:
                print(datetime.datetime.now())
                print(url)
                # selenium.common.exceptions.TimeoutException:
                # return self.download_acticles(url)
                return None
            finally:
                driver.quit()
项目:Needl    作者:eth0izzle    | 项目源码 | 文件源码
def get_browser():
    chromedriver = os.path.join(needl.args.datadir, 'chromedriver')
    if not os.path.exists(chromedriver):
        raise FileNotFoundError("Could not find chromedriver executable at %s. Download it for your platform at https://chromedriver.storage.googleapis.com/index.html?path=2.33/", chromedriver)

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('headless')
    chrome_options.add_argument('window-size=1024x3000')
    chrome_options.add_argument("user-agent=" + get_line(os.path.join(needl.args.datadir, 'user-agents.txt')))

    return webdriver.Chrome(executable_path=chromedriver, chrome_options=chrome_options)
项目:Pirka    作者:Mkohm    | 项目源码 | 文件源码
def __init__(self, username: str, password: str):
        """
        This method sets up scraper, and logs in to Its Learning. It enables the other methods to scrap
        content, like calendar feed, exercises and course list.
        :param username: FEIDE-username
        :param password: FEIDE-password
        """

        self.username = username
        self.password = password

        # Initializes the correct version of chromedriver with regards to OS
        driver_directory = os.path.dirname(__file__)
        if platform.system() == "Windows":
            relative_path = "chromedriver.exe"
        else:
            relative_path = "chromedriver"
        absolute_file_path = os.path.join(driver_directory, relative_path)
        chrome_profile = webdriver.ChromeOptions()
        self.driver = webdriver.Chrome(executable_path=absolute_file_path)

        self.driver.get("http://www.ilearn.sexy")  # Shortcut to itslearning

        # logs into Its Learning. After this the "driver" contains the main page in Its Learning
        username_field = self.driver.find_element_by_name("feidename")
        username_field.send_keys(username)
        password_field = self.driver.find_element_by_name("password")
        password_field.send_keys(password)
        password_field.submit()
项目:selenium_extensions    作者:pythad    | 项目源码 | 文件源码
def chrome_driver(executable_path=None, run_headless=False,
                  load_images=True, use_proxy=None):
    '''Function to initialize ``selenium.webdriver.Chrome`` with extended options

    Args:
        executable_path (str): path to the chromedriver binary. If set to ``None`` selenium will serach for ``chromedriver`` in ``$PATH``.
        run_headless (bool): boolean flag that indicates if chromedriver has to be headless (without GUI).
        load_images (bool): boolean flag that indicates if Chrome has to render images.
        use_proxy (str): use http proxy in <host:port> format.

    Returns:
        selenium.webdriver.Chrome: created driver.

    Note:
        In order to create Chrome driver Selenium requires `Chrome <https://www.google.com/chrome/browser/desktop/index.html>`_ to be installed and `chromedriver <https://sites.google.com/a/chromium.org/chromedriver/>`_ to be downloaded.

    Warning:
        Headless Chrome is shipping in Chrome 59 and in Chrome 60 for Windows. Update your Chrome browser if you want to use ``headless`` option.
    '''
    chrome_options = webdriver.ChromeOptions()
    if run_headless:
        chrome_options.add_argument('headless')
    if not load_images:
        prefs = {'profile.managed_default_content_settings.images': 2}
        chrome_options.add_experimental_option('prefs', prefs)
    if use_proxy:
        chrome_options.add_argument('proxy-server=' + use_proxy)
    if executable_path:
        driver = webdriver.Chrome(chrome_options=chrome_options,
                                  executable_path=executable_path)
    else:
        driver = webdriver.Chrome(chrome_options=chrome_options)
    return driver
项目:Spider    作者:poluo    | 项目源码 | 文件源码
def __init__(self):
        self.cookies = None
        path = "C:\Program Files (x86)\Google\Chrome\chromedriver.exe"
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--incognito")
        self.driver = webdriver.Chrome(service_args=['--load-images=no'], executable_path=path,
                                       chrome_options=chrome_options)
        self.action = ActionChains(self.driver)
        self.retry_login()
项目:insta_browser    作者:aLkRicha    | 项目源码 | 文件源码
def __init__(self, debug=False, chrome=False, cookie_path=None, log_path=None, db_path=None,
                 exclude=None):
        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        options.add_argument('--window-size=900,768')
        self.browser = webdriver.Chrome(chrome_options=options)
        self.browser.implicitly_wait(10)

        self.cookie_path = cookie_path
        self.exclude = exclude or []
        self.chrome = chrome
        self.logger = Logger(log_path, debug)
        self.db = BrowserDB(self.logger, db_path)
项目:python_selenium_astride    作者:reclamador    | 项目源码 | 文件源码
def setUp(self):
        self.app = self.create_app()
        options = webdriver.ChromeOptions()
        options.add_argument('headless')
        options.add_argument('disable-gpu')
        self.browser = webdriver.Chrome(options=options)
        self.browser.implicitly_wait(3)
项目:Taurauto-Sharer    作者:sameerkumar18    | 项目源码 | 文件源码
def __init__(self):
        self.url = 'https://www.facebook.com'
        chrome_options = webdriver.ChromeOptions()
        prefs = {"profile.default_content_setting_values.notifications": 2}
        chrome_options.add_experimental_option("prefs", prefs)
        self.driver = webdriver.Chrome(chrome_options=chrome_options)#,'__path__' maybe required for Windows
        self.driver.get(self.url)
项目:Taurauto-Sharer    作者:sameerkumar18    | 项目源码 | 文件源码
def __init__(self):
        self.url = 'https://www.facebook.com'
        chrome_options = webdriver.ChromeOptions()
        prefs = {"profile.default_content_setting_values.notifications": 2}
        chrome_options.add_experimental_option("prefs", prefs)
        self.driver = webdriver.Chrome(chrome_options=chrome_options)#,'__path__' maybe required for Windows
        self.driver.get(self.url)
项目:Taurauto-Sharer    作者:sameerkumar18    | 项目源码 | 文件源码
def __init__(self):
        self.url = 'https://www.facebook.com'
        chrome_options = webdriver.ChromeOptions()
        prefs = {"profile.default_content_setting_values.notifications": 2}
        chrome_options.add_experimental_option("prefs", prefs)
        self.driver = webdriver.Chrome(chrome_options=chrome_options)
        self.driver.maximize_window()
        self.driver.get(self.url)