标签:pytho end bsp python https drive 网页加载 element url
代码:
from selenium import webdriver url = ‘https://passport.baidu.com/v2/?login‘ username = ‘your_username‘ passwd = "your_password" driver = webdriver.Chrome() # 打开chrome浏览器 driver.get(url) # 打开指定的网页 input_username = driver.find_element_by_id("TANGRAM__PSP_3__userName") # 用户名输入框 input_passwd = driver.find_element_by_id("TANGRAM__PSP_3__password") # 密码输入狂 input_login = driver.find_element_by_id("TANGRAM__PSP_3__submit") # 登陆按钮 input_username.send_keys(username) # 输入框中输入用户名 input_passwd.send_keys(passwd) # 输入框中输入密码 input_login.click() # 点击登陆 driver.implicitly_wait(5) # 确保网页加载完毕 phone = driver.find_element_by_css_selector(".phone > a").text email = driver.find_element_by_css_selector(‘.email > a‘).text print(phone) # 打印手机号 print(email) # 打印邮箱 driver.close()
标签:pytho end bsp python https drive 网页加载 element url
原文地址:http://www.cnblogs.com/hupeng1234/p/7071182.html