Browse Source

allow to get more than 200 tweets for analysis

master
arnaucode 7 years ago
parent
commit
48656e5b16
2 changed files with 23 additions and 6 deletions
  1. +22
    -5
      getUser.go
  2. +1
    -1
      main.go

+ 22
- 5
getUser.go

@ -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)

+ 1
- 1
main.go

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

Loading…
Cancel
Save