Python+selenium Implementation 163 Automatic Mailbox Login

Source: Internet
Author: User
Tags email account

Let's start by previewing how the code works:

first analyze the page structure of 163 Mailbox Landing page (press F12 or right mouse button to select the review element)

1, positioning to the login box (note that the login box is an IFRAME, if you do not locate the IFRAME will not be able to find the Mailbox address box and password input box)

2. Locate the Email Address box (name= ' email ')

3. Locate the Password input box (name= ' password ')

4. Locate the login button (id= ' Dologin ')

5, analysis completed, can now write code to achieve 163 mailbox automatic landing (with the code of detailed analysis!) )
#Coding:utf-8 fromSeleniumImportWebdriverImport TimedefLogin (): Dr=Webdriver. Chrome ()#open a Web page with 163 mailboxesDr.get ('http://mail.163.com/')    #maximize the browser windowDr.maximize_window ()#rest five minutes waiting for Web page to loadTime.sleep (5)    #Locate the IFRAME for the Mailbox account login boxDr.switch_to.frame ('X-urs-iframe')    #Find the Email account entry boxemail = dr.find_element_by_name ('Email')    #Enter your e-mail address into the Mailbox account boxEmail.send_keys ('CHIMUYHS')    #Find the Password entry boxPassword = dr.find_element_by_name ('Password')    #Enter your own e-mail passwordPassword.send_keys ('xxxxxx')    #Locate the login buttonLOGIN_BTN = dr.find_element_by_id ('Dologin')    #Click the login buttonLogin_btn.click ()#wait 10 seconds to see if the landing is successful .Time.sleep (10)if __name__=='__main__': Login ()

Python+selenium Implementation 163 Automatic Mailbox Login

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.