Python and Selenium achieve 163 automatic mailbox Login

Source: Internet
Author: User
This article mainly introduced the Python+selenium realizes 163 mailbox Automatic landing method, the small compilation thought quite good, now shares to everybody, also gives everybody to make a reference. Follow the small series together to see it, hope to help everyone.

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 () #休息五分钟等待网页加载完毕 time.sleep (5) #找到邮箱账号登录框对应的iframe dr.switch_to.frame (' x-urs-iframe ') #找到邮箱账号输入框 email = dr.find_element_by_name (' email ') # Enter your email address into the Mailbox account box Email.send_keys (' chimuyhs ') #找到密码输入框 password = dr.find_element_by_name (' password ') #输入自己的邮箱密码 Pass   Word.send_keys (' xxxxxx ') #找到登陆按钮 login_btn = dr.find_element_by_id (' dologin ') #点击登陆按钮 Login_btn.click () #等待10秒看是否登陆成功 Time.sleep () if __name__ = = ' __main__ ': Login () 
Related Article

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.