吃饭睡觉打豆豆
二十出头的年纪,脚踏实地。毕竟青春只有一次
随笔 - 38,  文章 - 0,  评论 - 20,  阅读 - 20772
复制代码
 1 #实现163网站的注册
 2 from selenium import webdriver
 3 import time
 4 driver = webdriver.Chrome()
 5 url = 'https://mail.163.com/'
 6 driver.get(url)
 7 # 定位注册新账号
 8 el= driver.find_element_by_xpath('//*[@id="commonOperation"]/a[2]').click()
 9 time.sleep(5)
10 #切换句柄到注册页面
11 hand_list = driver.window_handles
12 driver.switch_to.window(hand_list[1])
13 driver.find_element_by_xpath('//*[@id="username"]').send_keys('17762443345@163.com')
14 driver.find_element_by_xpath('//*[@id="password"]').send_keys('cd123456')
15 driver.find_element_by_xpath('//*[@id="phone"]').send_keys('17762443345')
16 driver.find_element_by_xpath('/html/body/div[2]/div/div/div[2]/div[4]/span').click()
17 driver.find_element_by_xpath('/html/body/div[2]/div/div/div[2]/div[5]/a[1]').click()
18 #163网站登录
19 from selenium import webdriver
20 import  time
21 driver =webdriver.Chrome()
22 main_url="https://mail.163.com/"
23 driver.get(main_url)
24 time.sleep(3)
25 #点击切换到帐号密码登录
26 driver.find_element_by_id("switchAccountLogin").click()
27 #找到iframe
28 login_iframe=driver.find_element_by_xpath('//iframe[starts-with(@id, "x-URS-iframe")]')
29 driver.switch_to.frame(login_iframe)
30 username=driver.find_element_by_xpath('//input[@name="email"]')
31 password=driver.find_element_by_xpath('//input[@name="password"]')
32 username.send_keys("17762443354@163.com")
33 password.send_keys("cd123456")
34 driver.find_element_by_xpath('//a[@id="dologin"]').click()
35 driver.find_element_by_xpath('//*[@id="_mail_component_53_53"]').click()
复制代码

虽然自己不太熟悉,其中也会报错,每次红我就在想自己是不是真的不适合学代码。

好的程序员都是要一直敲敲敲还是要多练多练多练

 

posted on   测试小张  阅读(979)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示