我们通过python3的selenium进行模拟登陆操作
首先我们要确保已经安装有selenium
pip install selenium
而后我们应该有一个适配于selenium的浏览器驱动,PhantomsJS现在已经和selenium分道扬镳,这里建议大家用Chrome及其驱动chromedriver_win32(虽然叫win32但你的64位系统也可以用,不用去下所谓的“_win64”),把默认浏览器也设为Chrome。
#bower = webdriver.Chrome(chrome_options=.....,
executable_path = "D:/Python/chromedriver/chromedriver")
其中chrome_options指的是浏览器启动参数选项,默认会打开一个浏览器,可以设置无头浏览器,executable_path则是Chromewebdriver存放的路径,如果你设置了环境变量就不用写了。
之后.get()方法打开网站如
bower.get('https://leetcode-cn.com/')
webdriver寻找元素有几个比较简单的