Open IE Browser Window

后端 未结 7 497
梦谈多话
梦谈多话 2021-02-05 17:59

The webbrowser library provides a convenient way to launch a URL with a browser window through the webbrowser.open() method. Numerous browser types are available, b

相关标签:
7条回答
  • 2021-02-05 18:02

    Please try putting the absolute path of internet explorer exe file in your code.

    ie=webbrowser.get("C:\Program Files\Internet Explorer\iexplore.exe")
    ie.open_new("http://google.com") 
    
    0 讨论(0)
  • 2021-02-05 18:04
    >>> ie = webbrowser.get('c:\\program files\\internet explorer\\iexplore.exe')
    >>> ie.open('http://google.com')
    True
    
    0 讨论(0)
  • 2021-02-05 18:05

    If you plan to use the script in more than your machine, keep in mind that not everyone has a English version of Windows

    import subprocess
    import os
    
    subprocess.Popen(r'"' + os.environ["PROGRAMFILES"] + '\Internet Explorer\IEXPLORE.EXE" www.google.com')
    
    0 讨论(0)
  • 2021-02-05 18:07

    More elegant code:

    import webbrowser
    
    ie = webbrowser.get(webbrowser.iexplore)
    ie.open('google.com')
    
    0 讨论(0)
  • 2021-02-05 18:07

    You can always do something like

    subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" http://www.example.com')
    
    0 讨论(0)
  • 2021-02-05 18:08
    iexplore = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
        "Internet Explorer\\IEXPLORE.EXE")
    ie = webbrowser.BackgroundBrowser(iexplore)
    ie.open(...)
    

    This is what the webrowser module uses internally.

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