Search code examples
pythonpython-3.xwebbrowser-controlopera

How can i execute my webbrowser in Python?


I need to execute my webbrowser (opera) from python code, how can i get it?

Python version 3.6, OS MS Windows 7


Solution

  • Use webbrowser module in python.

    import webbrowser as wb
    wb.get('chrome %s').open_new_tab('http://www.google.com')
    

    You can open your default web browser in python this way by writing this command in cmd:

    python -mwebbrowser -n URL
    

    -n : new window

    Look at the webbrowser documentation to see other options as well.