广东网站开发推荐,wordpress快速加载,凡客诚品售后服务有哪些,溧阳做网站价格一、什么是selenium库#xff1f;
selenim是一个用于Web应用程序自动化测试工具#xff0c;selenium测试直接运行在浏览器中
像真正的用户在操作一样#xff0c;驱动浏览器执行特定的动作#xff0c;如点击#xff0c;下拉等操作
二、selenium在爬虫中的应用
获取动态…一、什么是selenium库
selenim是一个用于Web应用程序自动化测试工具selenium测试直接运行在浏览器中
像真正的用户在操作一样驱动浏览器执行特定的动作如点击下拉等操作
二、selenium在爬虫中的应用
获取动态网页中的数据一些动态的数据我们在获取的源码中并没有显示的这一类动态加载数据用于模拟登录
三、selenium库支持的浏览器
支持的浏览器包括phantomjs,IE(7,8,9,10,11)Mozilla FirefoxSafariGoogle ChromeOpera等 四、driver下载地址 firefox浏览器
https://github.com/mozilla/geckodriver/releases/Chrome浏览器
http://chromedriver.storage.googleapis.com/index.html
113-133版本
https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json134版本及以后
https://googlechromelabs.github.io/chrome-for-testing/
链接是实时更新的
4.1 selenium调用Chrome浏览器访问动态网页数据
查看Chrome版本
下载对应chromedriver并配置环境变量
查看
编写代码
import time
from selenium import webdrivertest_webdriver webdriver.Chrome(executable_pathD:\chromedriver\chromedriver-win64\chromedriver-win64\chromedriver.exe)test_webdriver.get(https://echarts.apache.org/examples/zh/index.html)for item in test_webdriver.find_elements_by_xpath(//div[classexample-title]):print(item.text)print(test_webdriver.title)
time.sleep(10)
test_webdriver.quit() 这样就可以访问动态网页数据