Python+selenium Auto-cycle e-mail

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.