我正在使用 chromedp 制作 scrapper。
要获得我想要的内容(页面 html),我必须单击特定按钮。
所以我使用了 chromedp.click 和 chromedp.outerhtml,但是我只得到了点击前页面的 html,而不是点击完成后页面的 html。
你能看看我的代码并建议我如何修复它吗?
func runCrawler(URL string, lineNum string, stationNm string) {
// settings for crawling
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("headless", false))
// create chrome instance
contextVar, cancelFunc := chromedp.NewExecAllocator(context.Background(), opts...)
defer cancelFunc()
contextVar, cancelFunc = chromedp.NewContext(contextVar)
defer cancelFunc()
var htmlContent string
err := chromedp.Run(contextVar,
chromedp.Navigate(URL),
chromedp.WaitVisible(".end_footer_area"),
chromedp.Click(".end_section.station_info_section > div.at_end.sofzqce > div > div.c10jv2ep.wrap_btn_schedule.schedule_time > button"),
chromedp.OuterHTML("html", &htmlContent, chromedp.ByQuery),
)
fmt.Println("html", htmlContent)
checkErr(err)
我也给你主页和按钮我需要点击
页面网址:https://pts.map.naver.com/end-subway/ends/web/11321/home
我需要点击的按钮区域:
非常感谢