func Collect(people people.People, opt *CollectOpt) ([]*Subject, *http.Response, error) {
	opt = mergeCollectOpts(opt)

	url, err := url.Parse(fmt.Sprintf("%s/people/%s/collect", basePath, people.Username))
	if err != nil {
		return nil, nil, err
	}
	q := url.Query()
	q.Set("start", "0")
	q.Set("filter", "all")
	q.Set("mode", "list")
	q.Set("sort", string(opt.SortBy))
	url.RawQuery = q.Encode()

	resp, err := crawler.DefaultClient.Get(url.String())
	if err != nil {
		return nil, resp, err
	}

	doc, err := goquery.NewDocumentFromResponse(resp)
	if err != nil {
		return nil, resp, err
	}

	var albums []*Subject

	doc.Find(".list-view .item").Each(func(_ int, s *goquery.Selection) {
		album := &Subject{}
		titleNode := s.Find(".title > a")
		url := titleNode.AttrOr("href", "")
		if url == "" {
			return
		}
		title := strings.TrimSpace(titleNode.Text())
		dateNode := s.Find(".date")
		date, err := time.Parse(COLLECT_DATE_FMT, strings.TrimSpace(dateNode.Text()))
		if err != nil {
			return
		}
		rating := parseRating(strings.TrimSpace(s.Find(".date > span").AttrOr("class", "")))

		album = &Subject{
			Url:         url,
			Title:       title,
			Rating:      rating,
			CollectDate: date,
		}

		albums = append(albums, album)
	})

	return albums, resp, nil
}
// Collect crawls douban user's movie collection
Collect crawls douban user's movie collection
// Collect crawls douban user ' s movie collection
func Collect(people people.People, opt *CollectOpt) ([]*Subject, *http.Response, error) {
	opt = mergeCollectOpts(opt)
	url, err := url.Parse(fmt.Sprintf("%s/people/%s/collect", basePath, people.Username))
	if err != nil {
		return nil, nil, err
	}
	q := url.Query()
	q.Set("start", "0")
	q.Set("filter", "all")
	q.Set("mode", "list")
	q.Set("sort", string(opt.SortBy))
	url.RawQuery = q.Encode()
	resp, err := crawler.DefaultClient.Get(url.String())
	if err != nil {
		return nil, resp, err
	}
	doc, err := goquery.NewDocumentFromResponse(resp)
	if err != nil {
		return nil, resp, err
	}
	var albums []*Subject
	doc.Find(".list-view .item").Each(func(_ int, s *goquery.Selection) {
		album := &Subject{}
		titleNode := s.Find(".title > a")
		url := titleNode.AttrOr("href", "")
		if url == "" {
			return
		}
		title := strings.TrimSpace(titleNode.Text())
		dateNode := s.Find(".date")
		date, err := time.Parse(COLLECT_DATE_FMT, strings.TrimSpace(dateNode.Text()))
		if err != nil {
			return
		}
		rating := parseRating(strings.TrimSpace(s.Find(".date > span").AttrOr("class", "")))
		album = &Subject{
			Url:         url,
			Title:       title,
			Rating:      rating,
			CollectDate: date,
		}
		albums = append(albums, album)
	})
	return albums, resp, nil
}
func Collect ( people people . People , opt * CollectOpt ) ( [ ] * Subject , * http . Response , error ) { opt = mergeCollectOpts ( opt ) url , err := url . Parse ( fmt . Sprintf ( " " , basePath , people . Username ) ) if err != nil { return nil , nil , err } q := url . Query ( ) q . Set ( " " , " " ) q . Set ( " " , " " ) q . Set ( " " , " " ) q . Set ( " " , string ( opt . SortBy ) ) url . RawQuery = q . Encode ( ) resp , err := crawler . DefaultClient . Get ( url . String ( ) ) if err != nil { return nil , resp , err } doc , err := goquery . NewDocumentFromResponse ( resp ) if err != nil { return nil , resp , err } var albums [ ] * Subject doc . Find ( " " ) . Each ( func ( _ int , s * goquery . Selection ) { album := & Subject { } titleNode := s . Find ( " " ) url := titleNode . AttrOr ( " " , " " ) if url == " " { return } title := strings . TrimSpace ( titleNode . Text ( ) ) dateNode := s . Find ( " " ) date , err := time . Parse ( COLLECT_DATE_FMT , strings . TrimSpace ( dateNode . Text ( ) ) ) if err != nil { return } rating := parseRating ( strings . TrimSpace ( s . Find ( " " ) . AttrOr ( " " , " " ) ) ) album = & Subject { Url : url , Title : title , Rating : rating , CollectDate : date , } albums = append ( albums , album ) } ) return albums , resp , nil }
Collect crawls douban user's movie collection
Collect crawls douban user ' s movie collection