1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python using webbroswer.open() to download a file

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I understand how to call chrome with webbrowser to access a url, however, if that url led to a download, how would I automatically save the file to an assigned destination?

    Here's what I have:

    import webbrowser
    import os

    url = 'https://videos.com/test.mp4'
    path = os.getcwd() + '/video.mp4'

    chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

    file = webbrowser.get(chrome_path).open(url)
    with open(path, "wb") as f:
    f.write(file)


    This wouldn't work as chrome asks for a destination when accessing the url, I would like for chrome to automatically save the file based on the inputs of python. I understand I can do this manually using chrome, however, I'll be downloading many videos, which is why I would like to save time.

    Is there any solution here or is this not possible?

    Continue reading...

Compartilhe esta Página