Skip to content

Instantly share code, notes, and snippets.

@akira093
Created July 6, 2014 14:36
Show Gist options
  • Select an option

  • Save akira093/f641247e26f8f8bff8dd to your computer and use it in GitHub Desktop.

Select an option

Save akira093/f641247e26f8f8bff8dd to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/ChimeraCoder/anaconda"
"math"
"net/url"
)
func reverseTWs(tws []anaconda.Tweet) []anaconda.Tweet {
n := len(tws) - 1
for i := 0; i < n/2; i++ {
tws[i], tws[n-i] = tws[n-i], tws[i]
}
return tws
}
func main() {
// api作ってる部分
var res []anaconda.Tweet
maxId := int64(math.MaxInt64)
v := url.Values{}
v.Set("count", "100")
for {
v.Set("max_id", fmt.Sprint(maxId))
tws, err := api.GetSearch("#提督と艦娘達のカーニバル", v)
if err != nil {
fmt.Println(err)
panic(err)
}
if len(tws) == 0 {
break
}
res = append(res, tws...)
t := res[len(res)-1]
maxId = t.Id - 1
}
res = reverseTWs(res)
for _, tw := range res {
fmt.Println(tw.Text)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment