1,selenium 是自动化测试以及自动化爬取的框架,常用于python开发,今天这里使用golang selenium进行自动化开发,相比python,主要是社区广泛,golang同样也是跟python功能一样,同时go可以支持大并发携程 自动化爬取节省资源,下面我们就直接上代码案例操作
1,首先需要下载谷歌驱动,并配置到环境变量,必须与chrom版本相同
版本对比网站
https://googlechromelabs.github.io/chrome-for-testing/
2,安装golang idea ,并配置golang环境变量
3,如果成功打开了谷歌浏览器,那么golang的selenium自动化配置完成,里面的代码自行配置了
核心代码
func LeisuSelenumTwo() {opts := []selenium.ServiceOption{selenium.Output(os.Stderr), // Output debug information to STDERR.}selenium.SetDebug(true)service, err := selenium.NewChromeDriverService(seleniumPath, port, opts