윤준석

HOTFIX: go-rod connection close

...@@ -84,7 +84,16 @@ func getItemsInfoByKeyword(keyword string) ([]model.ApiResponseItem, error) { ...@@ -84,7 +84,16 @@ func getItemsInfoByKeyword(keyword string) ([]model.ApiResponseItem, error) {
84 func crawlingNaverCafe(cafeUrl string) (*model.Item, error) { 84 func crawlingNaverCafe(cafeUrl string) (*model.Item, error) {
85 path, _ := launcher.LookPath() 85 path, _ := launcher.LookPath()
86 u := launcher.New().Bin(path).MustLaunch() 86 u := launcher.New().Bin(path).MustLaunch()
87 - frame := rod.New().ControlURL(u).MustConnect().MustPage(cafeUrl).MustElement("iframe#cafe_main") 87 +
88 + browser := rod.New().ControlURL(u).MustConnect()
89 + defer func(browser *rod.Browser) {
90 + err := browser.Close()
91 + if err != nil {
92 + log.Fatal(err)
93 + }
94 + }(browser)
95 +
96 + frame := browser.MustPage(cafeUrl).MustElement("iframe#cafe_main")
88 time.Sleep(time.Second * 2) 97 time.Sleep(time.Second * 2)
89 source := frame.MustFrame().MustHTML() 98 source := frame.MustFrame().MustHTML()
90 html, err := goquery.NewDocumentFromReader(bytes.NewReader([]byte(source))) 99 html, err := goquery.NewDocumentFromReader(bytes.NewReader([]byte(source)))
......