@@ -52,11 +52,14 @@ func Scrape(engine Engine) ([]Movie, error) {
5252 // Cache responses to prevent multiple download of pages
5353 // even if the collector is restarted
5454 colly .CacheDir ("./gophie_cache" ),
55- colly .Async (true ),
55+ // colly.Async(true),
5656 // colly.Debugger(&debug.LogDebugger{}),
5757 )
5858 // Another collector for download Links
59- downloadLinkCollector := c .Clone ()
59+ downloadLinkCollector := colly .NewCollector (
60+ colly .CacheDir ("./gophie-cache" ),
61+ colly .Async (true )
62+ )
6063
6164 var movies = make (map [string ]* Movie )
6265
@@ -75,9 +78,13 @@ func Scrape(engine Engine) ([]Movie, error) {
7578 } else {
7679 // Using DownloadLink as key to movie makes it unique
7780 movies [movie .DownloadLink .String ()] = & movie
78- downloadLinkCollector .Visit (movie .DownloadLink .String ())
81+ // downloadLinkCollector.Visit(movie.DownloadLink.String())
7982 }
8083 })
84+
85+ for _ , movie := range movies {
86+ downloadLinkCollector .Visit (movie .DownloadLink .String ())
87+ }
8188 })
8289
8390 c .OnRequest (func (r * colly.Request ) {
@@ -109,6 +116,7 @@ func Scrape(engine Engine) ([]Movie, error) {
109116 })
110117
111118 downloadLinkCollector .OnResponse (func (r * colly.Response ) {
119+ log .Debug (r .Request .URL .String )
112120 // movie := movies[r.Request.URL.String()]
113121 // log.Infof("%s %v %s", r.Request.URL.String(), movie.DownloadLink, movie.Title)
114122 // log.Debugf("Retrieved Download Link %v\n", movie.DownloadLink)
0 commit comments