allow to get more than 200 tweets for analysis

This commit is contained in:
arnaucode
2017-04-16 17:31:03 +02:00
parent 8456427b32
commit 48656e5b16
2 changed files with 23 additions and 6 deletions

View File

@@ -10,6 +10,25 @@ import (
"github.com/dghubble/go-twitter/twitter"
)
func getTweets(client *twitter.Client, username string, iterations int) []twitter.Tweet {
var tweets []twitter.Tweet
var maxid int64
for i := 0; i < iterations; i++ {
tweetsRaw, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
ScreenName: username,
Count: 200,
MaxID: maxid,
})
maxid = tweetsRaw[len(tweetsRaw)-1].ID
for _, v := range tweetsRaw {
tweets = append(tweets, v)
}
}
fmt.Println("total of " + strconv.Itoa(len(tweets)) + " tweets")
return tweets
}
func getUser(client *twitter.Client) {
newcommand := bufio.NewReader(os.Stdin)
fmt.Print("enter username: @")
@@ -19,12 +38,10 @@ func getUser(client *twitter.Client) {
fmt.Println("-----------------------")
//get tweets and analyze words and dates
tweets, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
ScreenName: username,
Count: 200,
})
//get tweets
tweets := getTweets(client, username, 2)
//now analyze words and dates
fmt.Println("word count")
analyzeWords(tweets)

View File

@@ -7,7 +7,7 @@ import (
"strings"
)
const minNumWords = 3
const minNumWords = 10
func main() {
fmt.Println("---------------")