mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
allow to get more than 200 tweets for analysis
This commit is contained in:
27
getUser.go
27
getUser.go
@@ -10,6 +10,25 @@ import (
|
|||||||
"github.com/dghubble/go-twitter/twitter"
|
"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) {
|
func getUser(client *twitter.Client) {
|
||||||
newcommand := bufio.NewReader(os.Stdin)
|
newcommand := bufio.NewReader(os.Stdin)
|
||||||
fmt.Print("enter username: @")
|
fmt.Print("enter username: @")
|
||||||
@@ -19,12 +38,10 @@ func getUser(client *twitter.Client) {
|
|||||||
|
|
||||||
fmt.Println("-----------------------")
|
fmt.Println("-----------------------")
|
||||||
|
|
||||||
//get tweets and analyze words and dates
|
//get tweets
|
||||||
tweets, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
|
tweets := getTweets(client, username, 2)
|
||||||
ScreenName: username,
|
|
||||||
Count: 200,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
//now analyze words and dates
|
||||||
fmt.Println("word count")
|
fmt.Println("word count")
|
||||||
analyzeWords(tweets)
|
analyzeWords(tweets)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user