selenium實現網易郵箱的登錄注冊


 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()

雖然自己不太熟悉,其中也會報錯,每次紅我就在想自己是不是真的不適合學代碼。

好的程序員都是要一直敲敲敲還是要多練多練多練

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM