Splinter automatic login

With foxfire default browser, if you go to the official website to download with chrome chromedriver drive, unzip into the directory under python scripts and then add environment variables, add the path chromedrvier under Path.

 

#import time
from splinter import Browser
def splinter(url):
    browser = Browser('chrome')
    browser.visit(url)
    #time.sleep(5)
    browser.find_by_id('Username').fill('userid')
    browser.find_by_id('Password').fill('userpassword')
    browser.find_by_id('LoginButton').click()
    info = []
    try:
        errinfo = browser.find_by_id('Error')
        errinfo = errinfo.text
        info.append(errinfo)
        print (info[5])
    except:
        print("Sucessful!")
    #time.sleep(0)  
    browser.quit()
  

 
if __name__=='__main__':
        website='http://url'
        Sliver (website)

  

Guess you like

Origin www.cnblogs.com/luoye00/p/11459414.html