selenium设置Chrome浏览器不出现通知,设置代理IP

from selenium import webdriver

PROXY = ""
chrome_options = webdriver.ChromeOptions()
prefs = {
    "profile.default_content_setting_values" :
        {
        "notifications" : 2
         },
     "profile.managed_default_content_settings.images" : 2
}
chrome_options.add_argument('--proxy-server={0}'.format(PROXY))     # 设置代理
chrome_options.add_experimental_option("prefs",prefs)               #设置浏览器不出现通知
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.implicitly_wait(10)
driver.get("https://www.facebook.com/")
driver.find_element_by_xpath('//*[@id="email"]').send_keys("2549433022@qq.com")    #输入账号密码
driver.find_element_by_xpath('//*[@id="pass"]').send_keys("jiaying1026")

driver.find_element_by_xpath('//*[@id="loginbutton"]/input').click()

 

posted @ 2019-01-15 17:00  小鳄鱼DL  阅读(1617)  评论(0编辑  收藏  举报