聚合云播

排序

北方小镇奇谈剧情简介

使用分词请去除后面的"}*/type CineMovieCrawler struct {}func (this *CineMovieCrawler) GetCrawlId() int { return 1}func (this *CineMovieCrawler) GetCrawlName() string { return CRAWLER_NAME_CINEMOVIE}func (this *CineMovieCrawler) GetUri() string { return CRAWLER_URI_CINEMOVIE}func (this *CineMovieCrawler) GetMethod() string { return http.MethodGet}func (this *CineMovieCrawler) GetParam(inputs map[string]interface{}) map[string]string { //return map[string]string{"cinema_code": "1202", "cinema_date": "2019-10-19", "film_code":"1900000071"} sCinemaCode, _ := inputs["cinema_code"].(string) sCinemaDate, _ := inputs["cinema_date"].(string) sFilmCode, _ := inputs["film_code"].(string) return map[string]string{"cinema_code": sCinemaCode, "cinema_date": sCinemaDate, "film_code": sFilmCode}}func (this *CineMovieCrawler) GetHeader(inputs map[string]interface{}) map[string]string { return nil}func (this *CineMovieCrawler) GetCookie(inputs map[string]interface{}) map[string]string { return nil}func (this *CineMovieCrawler) Parse(context *gin.Context, resp *http.Response) { doc, err := goquery.NewDocumentFromReader(resp.Body) if err != nil { log.Fatal(err) } //获取电影名称 sMovieTitle := "" doc.Find(".post-desc-title").Each(func(i int, s *goquery.Selection) { sMovieTitle = s.Text() }) //获取剧情名称 sIntroTitle := "" doc.Find(".post-desc-desc").Each(func(i int, s *goquery.Selection) { sIntroTitle = strings.TrimSpace(s.Text()) }) //获取剧情 sIntro := "" doc.Find(".desc-content").Each(func(i int, s *goquery.Selection) { sIntro = strings.TrimSpace(s.Text()) }) //获取电影详细信息 sMovieInfo := "" doc.Find(".post-desc-list").Each(func(i int, s *goquery.Selection) { if i == 0 { sMovieInfo = strings.TrimSpace(s.Text()) } }) //获取影片详细介绍 sMovieContent := "" doc.Find(".desc-main-body").Each(func(i int, s *goquery.Selection) { sMovieContent = strings.TrimSpace(s.Text()) }) //返回数据 result := make(map[string]interface{}) result["movie_title"] = sMovieTitle result["intro_title"] = sIntroTitle result["intro"] = sIntro result["movie_info"] = sMovieInfo result["movie_content"] = sMovieContent sendResult(context, util.BuildResponse(MOVIE_RES_CODE_SUCCESS, MOVIE_RES_MSG_SUCCESS, result))}func init(){ fmt.Println("cine_movie_crawler is starting")}