golang webdriver

최원상·2023년 1월 16일
0

golang을 이용하여 웹크롤링 프로그램 제작 진행 중..

package main

import (
	"log"
	"strings"
	"github.com/fedesog/webdriver"
	"golang.org/x/net/html"
)

func checkErr(err error) {
	if err != nil {
		log.Fatalln(err)
	}
}


func main() {
	//web driver 실행
	chromedriver := webdriver.NewChromeDriver("./chromedriver")
	driverRunErr := chromedriver.Start()
	checkErr(driverRunErr)

	//session 실행
	desired := webdriver.Capabilities{"Platform": "Linux"}
	required := webdriver.Capabilities{}

	session, err := chromedriver.NewSession(desired, required)
	checkErr(err)

	openURLerr := session.Url("https://www.youtube.com/@paik_jongwon/videos")
	checkErr(openURLerr)

	// 페이지 소스 추출 
	resp, err := session.Source()
	checkErr(err)

	htmlNode, err := html.Parse(strings.NewReader(resp))
	checkErr(err)
	log.Println(htmlNode)
	defer func() {
		session.Delete()
		chromedriver.Stop()
	}()



}

우선 예제코드 작성 후 돌려봤으나

2023/01/16 11:35:52 An unknown server-side error occurred while processing the command.: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=102.0.5005.61 (0e59bcc00cc4985ce39ad31c150065f159d95ad3-refs/branch-heads/5005@{#819}),platform=Linux 5.4.0-131-generic x86_64)
exit status 1

에러 발생.....

해당 에러 검색시 파이썬을 에러만 나옴..

profile
한 줄로는 안되지

0개의 댓글