我正在使用 GoColly 框架來獲取一些 url 的正文?,F在我正在測試 Netflix 網站,下面有這段代碼u = "http://netflix.com"uri, err := url.Parse(u)if err != nil { fmt.Println(err.Error()) continue}c := colly.NewCollector()c.AllowedDomains = []string{"netflix.com"}c.OnResponse(func(r *colly.Response) { q.r.Set("success:"+u, string(r.Body))})c.OnError(func(r *colly.Response, err error) { log.Println(err.Error()) q.r.Set("failed:"+u, err.Error())})c.Visit(uri.String())c.Wait()我正在使用 GoColly 框架來獲取一些 url 的正文?,F在我正在測試 Netflix 網站,下面有這段代碼u = "http://netflix.com"uri, err := url.Parse(u)if err != nil { fmt.Println(err.Error()) continue}c := colly.NewCollector()c.AllowedDomains = []string{"netflix.com"}c.OnResponse(func(r *colly.Response) { q.r.Set("success:"+u, string(r.Body))})c.OnError(func(r *colly.Response, err error) { log.Println(err.Error()) q.r.Set("failed:"+u, err.Error())})c.Visit(uri.String())c.Wait()當我執行它時,它會返回此錯誤Get https://www.netflix.com/ : Not following redirect to www.netflix.com because its not in AllowedDomains有什么想法嗎?
1 回答

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
c.AllowedDomains = []string{"netflix.com"}
您在此處指定了沒有子域的域www
,這就是在允許的域中找不到它的原因。
c.AllowedDomains = []string{"www.netflix.com"}
- 1 回答
- 0 關注
- 175 瀏覽
添加回答
舉報
0/150
提交
取消