问题描述
我想抓取Ajax页面。戈科利没有。我决定用chromepd模拟它。我的问题是我不知道如何将新的html页面传递给gocolly。
func main() {
c := colly.NewCollector()
c.OnHTML("a",func(e *colly.HTMLElement) {
e.Request.Visit(e.Attr("href"))
})
c.OnRequest(func(r *colly.Request) {
ctx,cancel := chromedp.NewContext(context.Background())
defer cancel()
var body string
if err := chromedp.Run(ctxt,chromedp.Navigate(r.URL.String()),chromedp.OuterHTML("html",&body),);
r.Ctx.Put("body",body)
})
// After making a request get "url" from
// the context of the request
c.OnResponse(func(r *colly.Response) {
fmt.Println(string(r.Body))
})
c.Visit("http://go-colly.org/")
}
*此代码无效
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)