The selenium browsers code below starts several web browsers. They open a website and then close the browser. The web drivers must be installed for this to work.
#-*- coding:utf-8 -*- from selenium import webdriver import time from tomorrow import threads
defstartBrowser(name): """ browsers,"firefox"、"chrome"、"ie"、"phantomjs" """ try: if name == "firefox"or name == "Firefox"or name == "ff": print("start browser name :Firefox") driver = webdriver.Firefox() return driver elif name == "chrome"or name == "Chrome": print("start browser name :Chrome") driver = webdriver.Chrome() return driver elif name == "ie"or name == "Ie": print("start browser name :Ie") driver = webdriver.Ie() return driver elif name == "phantomjs"or name == "Phantomjs": print("start browser name :phantomjs") driver = webdriver.PhantomJS() return driver else: print("Not found this browser,You can use ‘firefox‘, ‘chrome‘, ‘ie‘ or ‘phantomjs‘") except Exception as msg: print("message: %s" % str(msg))