美文网首页
chromedriver 设置下载路径和静止弹窗(seleniu

chromedriver 设置下载路径和静止弹窗(seleniu

作者: 绝世一只猫 | 来源:发表于2018-12-13 22:26 被阅读0次
  1. 导入模块
from selenium import webdriver
import time
  1. 添加配置
    download.default_directory:指定路径
    profile.default_content_settings.popups:0 为屏蔽弹窗,1 为开启弹窗
options = webdriver.ChromeOptions()
prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': 'd:\\'}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(chrome_options=options)

3.测试一下

driver.get('http://xiazai.sogou.com/detail/34/13/-5413726773704791742.html?uID=939557705037990A000000005C126455')
driver.find_element_by_xpath('//*[@id="sogouhighdown"]').click()
input(是否成功?)
driver.quit()

相关文章

网友评论

      本文标题:chromedriver 设置下载路径和静止弹窗(seleniu

      本文链接:https://www.haomeiwen.com/subject/ggapfftx.html