163 Mailbox Automatic Login Python+selenium

Source: Internet
Author: User

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-8from Selenium import webdriverimport timedef login ():    dr = Webdriver. Chrome ()    #打开登陆163邮箱的网页    dr.get (' http://mail.163.com/')    #将浏览器窗口最大化    Dr.maximize_window ()    # Rest five minutes to wait for the page to load    time.sleep (5)    #找到邮箱账号登录框对应的iframe    dr.switch_to.frame (' x-urs-iframe ')    #找到邮箱账号输入框    email = dr.find_element_by_name (' email ')    #将自己的邮箱地址输入到邮箱账号框中    email.send_keys (' chimuyhs ')    # Find the Password input box    password = dr.find_element_by_name (' password ')    #输入自己的邮箱密码    password.send_keys (' xxxxxx ')    #找到登陆按钮    login_btn = dr.find_element_by_id (' dologin ')    #点击登陆按钮    Login_btn.click ()    # Wait 10 seconds to see if the login succeeds    time.sleep ()    if __name__ = = ' __main__ ':    login ()

  

163 Mailbox Automatic Login Python+selenium

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.