python+selenium+webdriver+BeautifulSoup实现自动登录

Posted 木东

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python+selenium+webdriver+BeautifulSoup实现自动登录相关的知识,希望对你有一定的参考价值。

from selenium import webdriver
import time
from bs4 import BeautifulSoup

url = "http://www.hsbkos.com/"
soup = BeautifulSoup()
soup.findAll(‘div‘,{‘class‘:‘objbox‘})
driver = webdriver.Chrome()
time.sleep(1)
driver.get(url)
time.sleep(1)
driver.maximize_window()
loginButton = driver.find_element_by_id(‘loginin‘).click()

memberUsername = driver.find_element_by_name(‘memberUsername‘)
userPwd = driver.find_element_by_name(‘userPwd‘)
submitButton = driver.find_element_by_tag_name("strong")

memberUsername.send_keys(‘17364550000‘)
userPwd.send_keys(‘******‘)
time.sleep(1)
submitButton.click()
time.sleep(1)

  

以上是关于python+selenium+webdriver+BeautifulSoup实现自动登录的主要内容,如果未能解决你的问题,请参考以下文章

Selenium WebDriver(Python)API

[python] python+selenium+webdriver

[python] python+selenium+webdriver

selenium webdriver (python)大全

python+selenium—webdriver入门

转载selenium+Python WebDriver之selenium的定位以及切换frame(iframe)