最近接到一个特殊需求,需要每天定时截图某网站首页,保存备查,因此使用JAVA实现了后台截图。 下面是完整的方法。 JAVA实现浏览器截图,浏览器选用的是chrome,使用selenium-java依赖。selenium可以帮助我们调用浏览器,完成想要的功能。 由于是后台截图,不需要显示界面,chrome也支持不显示界面的调用。 selenium使用的是 较新的版本4.18.1 (截止2024-3-8)。 java版本为21(应该是11以及后,或者8也可以) 使用了hutool工具包。 首先,我们在windows上开发,需要下载最新的chrome浏览器和他对应的driver,下载地址为: https://chromedriver.chromium.org/downloads 根据下载界面的介绍,chrome115版本及以后的,下载地址为: https://googlechromelabs.github.io/chrome-for-testing/ 下载自己架构的windows版本 chromedriver。 pom: <dependency>...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with import cn.hutool.core.thread.Thread
Contact import cn.hutool.core.thread.Thread, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack