python simulation login 163 mailbox
- 2021-08-21 21:03:34
- OfStack
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
def login():
acount_num = input(' Please enter your account number :\n')
passwd_str = input(' Please enter your password :\n')
driver = webdriver.Edge()
url = 'http://mail.163.com/'
driver.get(url)
# Wait for the page to load, and you can click to log in with the password button
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.ID, 'lbNormal')))
driver.find_element_by_id('lbNormal').click()
# Use CSSSelector Regular matching header
elem = driver.find_element_by_css_selector("iframe[id^='x-URS-iframe']")
# 163 The login box is used iframe Is nested, so you need to switch to the iframe
driver.switch_to.frame(elem)
account_el = driver.find_element_by_xpath('//input[@name="email"]')
account_el.clear()
account_el.send_keys(acount_num)
password_el = driver.find_element_by_xpath('//input[@name="password"]')
password_el.clear()
password_el.send_keys(passwd_str)
login_el = driver.find_element_by_xpath('//a[@id="dologin"]')
login_el.click()
time.sleep(10)
cur_cookies = driver.get_cookies()
return cur_cookies
if __name__ == '__main__':
login()
Above is python simulation login 163 mailbox details, more about python simulation login information please pay attention to this site other related articles!