The Python code is as follows:
#Coding=utf-8 fromSeleniumImportWebdriver fromTimeImportSleep fromRandomImportRandintdefauto_throw (username, password):"" " Automatic loopThrowing Bottles"""Driver=Webdriver. Chrome () Driver.get ("https://mail.qq.com")
Driver.maxmize_window () # Maximize window sleep (1) #Toggle IFrame FormDriver.switch_to.frame ("Login_frame") Driver.find_element_by_xpath ('//*[@id = "U"]'). Send_keys (username) # User name Driver.find_element_by_xpath ('//*[@id = "P"]'). Send_keys (password) # password Driver.find_element_by_xpath ('//*[@id = "Login_button"]'). Click () # Login#Tanche The table back to the outermost layerdriver.switch_to.default_content () Sleep (2) I=0 M=0#Cycle the bottle whileTrue:Try: Driver.find_element_by_xpath ('//*[@id = "Folder_11"]/b[1]'). Click ()#Drifting BottleSleep (1) #Toggle IFrame FormDriver.switch_to.frame ("MainFrame") Sleep (1) Driver.find_element_by_xpath ('//*[@id = "Toolbar"]/div/a[1]'). Click ()#throw aSleep (1) Driver.find_element_by_xpath ('//*[@id = "Bottle_magic"]/div/div[1]/a[1]/span'). Click ()#Ordinary BottleSleep (1) Driver.find_element_by_xpath ('//*[@id = "Bottle_send"]/div[2]/div[1]/div[4]/div[2]/div[1]/textarea'). Send_keys ("Stranger
Your lucky number is%d!."%randint (1,10000)) Sleep (2) Driver.find_element_by_xpath ('//*[@id = "Bottle_send"]/div[2]/div[2]/div[3]/a[2]'). Click ()#throw it out . #Tanche The table back to the outermost layerdriver.switch_to.default_content () m+ = 1Print("the first%d bottles were successfully thrown out!"%m) Sleep (2) except: Print("throwing a bottle or throwing a bottle is running out of chance!") I+ = 1ifI > 10: Print("The chance to throw the bottle is running out!") Breakif __name__=='__main__':
Print ("--------automatically cycle lost QQ mailbox Drift bottle script--------")
Username = input ("Enter your QQ mailbox user name:")
Password = input ("Enter your QQ email login password:")
Auto_throw (username, password)
Python+selenium Auto-cycle throw QQ mailbox Drifting bottle