Downloading a file at a specified location through python and selenium using Chrome driver

后端 未结 8 1490
囚心锁ツ
囚心锁ツ 2020-12-01 02:56

I am trying to automatically download some links through selenium\'s click functionality and I am using a chrome webdriver and python as the programming lan

相关标签:
8条回答
  • 2020-12-01 03:40

    Using prefs solved my problem

    path = os.path.dirname(os.path.abspath(__file__))
    prefs = {"download.default_directory":path}
    options = Options()
    options.add_experimental_option("prefs", prefs)
    driver = webdriver.Chrome('../harveston/chromedriver.exe',options = options)
    
    0 讨论(0)
  • 2020-12-01 03:40

    To provide download directory and chrome's diver executable path use the following code.

    from selenium import webdriver
    options = webdriver.ChromeOptions() 
    options.add_argument("download.default_directory=C:/Your_Directory")
    driver = webdriver.Chrome(options=options ,executable_path='C:/chromedriver')
    

    change the path in your code accordingly.

    0 讨论(0)
提交回复
热议问题