add fetch tweets by userID func
This commit is contained in:
parent
e30b24e903
commit
76b2215e59
1 changed files with 9 additions and 4 deletions
13
tweets.go
13
tweets.go
|
|
@ -18,15 +18,20 @@ func GetTweets(ctx context.Context, user string, maxTweetsNbr int) <-chan *Tweet
|
|||
|
||||
// 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) {
|
||||
if maxTweetsNbr > 200 {
|
||||
maxTweetsNbr = 200
|
||||
}
|
||||
|
||||
userID, err := s.GetUserIDByScreenName(user)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return s.FetchTweetsByUserID(userID, maxTweetsNbr, cursor)
|
||||
}
|
||||
|
||||
// FetchTweetsByUserID gets tweets for a given userID, via the Twitter frontend API.
|
||||
func (s *Scraper) FetchTweetsByUserID(userID string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) {
|
||||
if maxTweetsNbr > 200 {
|
||||
maxTweetsNbr = 200
|
||||
}
|
||||
|
||||
req, err := s.newRequest("GET", "https://api.twitter.com/2/timeline/profile/"+userID+".json")
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue