add GetTweetsAndReplies and FetchTweetsAndReplies
This commit is contained in:
parent
0e07e464ba
commit
ec5d5dc117
4 changed files with 36 additions and 0 deletions
15
tweets.go
15
tweets.go
|
|
@ -12,6 +12,11 @@ func (s *Scraper) GetTweets(ctx context.Context, user string, maxTweetsNbr int)
|
|||
return getTweetTimeline(ctx, user, maxTweetsNbr, s.FetchTweets)
|
||||
}
|
||||
|
||||
// GetTweetsAndReplies returns channel with tweets and replies for a given user.
|
||||
func (s *Scraper) GetTweetsAndReplies(ctx context.Context, user string, maxTweetsNbr int) <-chan *TweetResult {
|
||||
return getTweetTimeline(ctx, user, maxTweetsNbr, s.FetchTweetsAndReplies)
|
||||
}
|
||||
|
||||
// FetchTweets gets tweets for a given user, via the Twitter frontend API.
|
||||
func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
|
||||
userID, err := s.GetUserIDByScreenName(user)
|
||||
|
|
@ -25,6 +30,16 @@ func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*
|
|||
return s.FetchTweetsByUserID(userID, maxTweetsNbr, cursor)
|
||||
}
|
||||
|
||||
// FetchTweetsAndReplies gets tweets and replies for a given user, via the Twitter frontend API.
|
||||
func (s *Scraper) FetchTweetsAndReplies(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
|
||||
userID, err := s.GetUserIDByScreenName(user)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return s.FetchTweetsAndRepliesByUserID(userID, maxTweetsNbr, cursor)
|
||||
}
|
||||
|
||||
// FetchTweetsAndRepliesByUserID gets tweets and replies for a given userID, via the Twitter frontend GraphQL API.
|
||||
func (s *Scraper) FetchTweetsAndRepliesByUserID(userID string, maxReplysNbr int, cursor string) ([]*Tweet, string, error) {
|
||||
if maxReplysNbr > 200 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue