The Python source code is as follows:
#Coding=utf-8 fromSeleniumImportWebdriver fromTimeImportSleep fromRandomImportRandintdefAuto_throw (target_qq, username, password):"""Auto-cycle e-mail"""Driver=Webdriver. Chrome () Driver.get ("https://mail.qq.com") Driver.set_window_size (1100, 580) Sleep (1) #Toggle IFrame FormDriver.switch_to.frame ("Login_frame") Driver.find_element_by_xpath ('//*[@id = "U"]'). Send_keys (username) Driver.find_element_by_xpath ('//*[@id = "P"]'). Send_keys (password) driver.find_element_by_xpath ('//*[@id = "Login_button"]'). Click () Sleep (1) #Tanche The table back to the outermost layerdriver.switch_to.default_content () Sleep (2) M=0 whileTrue:Try: M+ = 1driver.switch_to.default_content () Driver.find_element_by_xpath ('//*[@id = "COMPOSEBTN"]'). Click () Sleep (1) Driver.switch_to.frame ("MainFrame") #Driver.find_element_by_xpath ('//div[@title = "Stranger"]/a '). Click () # Buddy GroupDriver.find_element_by_xpath ('//a[@title = "%[email protected]"'%TARGET_QQ). Click ()#Select FriendsSleep (1) Driver.find_element_by_xpath ('//input[@title = "Subject is the title of an e-mail message, which is not filled in. "]'). Send_keys ("message%d sent successfully! Random code is%d!"% (M, Randint (100000,1000000)))#ThemeDriver.find_element_by_xpath ('//a[@name = "SENDBTN"]'). Click ()Print("message%d sent successfully!"%m) Sleep (1) except: Print("Send failed!") Sleep (1)if __name__=='__main__': Print("--------Automatically send e-mail--------") Target_qq= Input ("Please enter the other QQ number:") Username= Input ("Enter your QQ email user name:") Password= Input ("Enter your QQ e-mail login password:") Auto_throw (target_qq, username, password)
Python+selenium Auto-cycle e-mail