selenium-java web自动化测试工具抓取百度搜索结果实例
这种方式抓百度的搜索关键字结果非常容易
抓长尾关键词,根据热门关键词去抓更多内容可以用
抓google,百度的这种内容容易给屏蔽,用这种就不会了
1.新建maven项目,引入selenium-java
org.seleniumhq.selenium
selenium-java
3.8.1
2.写代码(因为自动化测试速度极快,每个步骤后都稍微停顿了下方便看效果)
packagecom.testselenium;importjava.util.concurrent.TimeUnit;importorg.openqa.selenium.By;importorg.openqa.selenium.JavascriptExecutor;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.chrome.ChromeDriver;public classAutoTest {public static void main(String[] args) throwsException {//谷歌浏览器的驱动下载地址:ht