From ac600dad61eac5c47c701018ff978082cc445ecd Mon Sep 17 00:00:00 2001 From: Zack Date: Sat, 16 Mar 2019 19:28:21 -0700 Subject: [PATCH 1/4] Add 126mail --- 126email/126email.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 126email/126email.py diff --git a/126email/126email.py b/126email/126email.py new file mode 100644 index 0000000..a88de2e --- /dev/null +++ b/126email/126email.py @@ -0,0 +1,32 @@ +import time +from selenium import webdriver + + +def login(): + acount_num = input('请输入账号:\n') + passwd_str = input('请输入密码:\n') + driver = webdriver.Chrome() + url = 'http://mail.126.com/' + driver.get(url) + time.sleep(30) + # # 126登陆框是使用iframe进行嵌套的,所以需要先切换到该iframe + # driver.switch_to.frame('x-URS-iframe') + + # acount = driver.find_element_by_name('email') + # acount.clear() + # acount.send_keys(acount_num) + + # passwd = driver.find_element_by_name('password') + # passwd.clear() + # passwd.send_keys(passwd_str) + + # time.sleep(3) + # click_button = driver.find_element_by_id('dologin') + # click_button.click() + # time.sleep(5) + # cur_cookies = driver.get_cookies()[0] + # return cur_cookies + + +if __name__ == '__main__': + login() From 491d89b31ee1047205bc9ef565f77590a00517f9 Mon Sep 17 00:00:00 2001 From: Yuqi Zheng Date: Sat, 16 Mar 2019 20:55:55 -0700 Subject: [PATCH 2/4] Add Notes --- Notes.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Notes.md diff --git a/Notes.md b/Notes.md new file mode 100644 index 0000000..9150b83 --- /dev/null +++ b/Notes.md @@ -0,0 +1,3 @@ +### IFrame + +An **IFrame** (Inline Frame) is an HTML document embedded inside another HTML document on a website. \ No newline at end of file From 1f130e86dc7f8640433823ffd5590a0bcdbdfbc0 Mon Sep 17 00:00:00 2001 From: Zack Date: Wed, 20 Mar 2019 12:27:49 -0700 Subject: [PATCH 3/4] Fixed 163email --- 126email/126email.py | 28 +++++++++++++++------------- 163email/163email.py | 5 ++++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/126email/126email.py b/126email/126email.py index a88de2e..6d27b6c 100644 --- a/126email/126email.py +++ b/126email/126email.py @@ -9,23 +9,25 @@ def login(): url = 'http://mail.126.com/' driver.get(url) time.sleep(30) + + elem = driver.find_element_by_css_selector("iframe[id^='x-URS-iframe']") # # 126登陆框是使用iframe进行嵌套的,所以需要先切换到该iframe - # driver.switch_to.frame('x-URS-iframe') + driver.switch_to.frame(elem) - # acount = driver.find_element_by_name('email') - # acount.clear() - # acount.send_keys(acount_num) + acount = driver.find_element_by_name('email') + acount.clear() + acount.send_keys(acount_num) - # passwd = driver.find_element_by_name('password') - # passwd.clear() - # passwd.send_keys(passwd_str) + passwd = driver.find_element_by_name('password') + passwd.clear() + passwd.send_keys(passwd_str) - # time.sleep(3) - # click_button = driver.find_element_by_id('dologin') - # click_button.click() - # time.sleep(5) - # cur_cookies = driver.get_cookies()[0] - # return cur_cookies + time.sleep(3) + click_button = driver.find_element_by_id('dologin') + click_button.click() + time.sleep(5) + cur_cookies = driver.get_cookies()[0] + return cur_cookies if __name__ == '__main__': diff --git a/163email/163email.py b/163email/163email.py index c75d8ad..100a992 100755 --- a/163email/163email.py +++ b/163email/163email.py @@ -9,8 +9,11 @@ def login(): url = 'http://mail.163.com/' driver.get(url) time.sleep(30) + + # 使用CSSSelector正则匹配头部 + elem = driver.find_element_by_css_selector("iframe[id^='x-URS-iframe']") # 163登陆框是使用iframe进行嵌套的,所以需要先切换到该iframe - driver.switch_to.frame('x-URS-iframe') + driver.switch_to.frame(elem) acount = driver.find_element_by_name('email') acount.clear() From c83a2d38be47b9391f1de5feda2b9cd29462a4cd Mon Sep 17 00:00:00 2001 From: Zack Date: Wed, 20 Mar 2019 12:32:22 -0700 Subject: [PATCH 4/4] Detele Notes --- Notes.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Notes.md diff --git a/Notes.md b/Notes.md deleted file mode 100644 index 9150b83..0000000 --- a/Notes.md +++ /dev/null @@ -1,3 +0,0 @@ -### IFrame - -An **IFrame** (Inline Frame) is an HTML document embedded inside another HTML document on a website. \ No newline at end of file