From c29869a57aed11b92e4e08f50b9fc239bf9f28fd Mon Sep 17 00:00:00 2001 From: MewX Date: Tue, 27 Dec 2022 10:17:41 +1100 Subject: [PATCH] Fixed hard-coded user names --- task/collector.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/task/collector.go b/task/collector.go index ed71c1b..80488f0 100644 --- a/task/collector.go +++ b/task/collector.go @@ -55,8 +55,8 @@ func (task *Collector) Precheck() error { return err } else { task.outputDir = path + log.Println("New output path saved:", task.outputDir) } - log.Println("New output path saved:", task.outputDir) // Check user existence. exists := true @@ -237,7 +237,7 @@ func (task *Collector) crawlBookListDispatcher() error { func (task *Collector) crawlBookLists(totalItems int, tag string, urlAction string) error { const pageStep = 15 - urlTemplate := fmt.Sprintf("https://book.douban.com/people/mewcatcher/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", urlAction) + urlTemplate := fmt.Sprintf("https://book.douban.com/people/%s/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", task.user, urlAction) return task.crawlItemLists(proto.Category_book, totalItems, pageStep, tag, urlTemplate) } @@ -292,7 +292,7 @@ func (task *Collector) crawlMovieListDispatcher() error { func (task *Collector) crawlMovieLists(totalItems int, tag string, urlAction string) error { const pageStep = 15 - urlTemplate := fmt.Sprintf("https://movie.douban.com/people/mewcatcher/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", urlAction) + urlTemplate := fmt.Sprintf("https://movie.douban.com/people/%s/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", task.user, urlAction) return task.crawlItemLists(proto.Category_movie, totalItems, pageStep, tag, urlTemplate) } @@ -347,7 +347,7 @@ func (task *Collector) crawlGameListDispatcher() error { func (task *Collector) crawlGameLists(totalItems int, tag string, urlAction string) error { const pageStep = 15 - urlTemplate := fmt.Sprintf("https://www.douban.com/people/mewcatcher/games?action=%s&start=%%d", urlAction) + urlTemplate := fmt.Sprintf("https://www.douban.com/people/%s/games?action=%s&start=%%d", task.user, urlAction) return task.crawlItemLists(proto.Category_game, totalItems, pageStep, tag, urlTemplate) } @@ -401,8 +401,7 @@ func (task *Collector) crawlMusicListDispatcher() error { func (task *Collector) crawlMusicLists(totalItems int, tag string, urlAction string) error { const pageStep = 15 - // FIXME: user name. - urlTemplate := fmt.Sprintf("https://music.douban.com/people/mewcatcher/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", urlAction) + urlTemplate := fmt.Sprintf("https://music.douban.com/people/%s/%s?start=%%d&sort=time&rating=all&filter=all&mode=grid", task.user, urlAction) return task.crawlItemLists(proto.Category_music, totalItems, pageStep, tag, urlTemplate) }