-
-
Save tmcw/24675d638645d5a8d6989ed1f93f59e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/csv" | |
"fmt" | |
"github.com/ChimeraCoder/anaconda" | |
"io" | |
"log" | |
"strconv" | |
// "strings" | |
// "net/url" | |
"os" | |
) | |
// Main for tweets up to the limit | |
// func main() { | |
// anaconda.SetConsumerKey("") | |
// anaconda.SetConsumerSecret("") | |
// api := anaconda.NewTwitterApi("", "") | |
// var deleted int64 = 0 | |
// | |
// for { | |
// params := url.Values{ | |
// "screen_name": []string{"tmcw"}, | |
// "count": []string{"1000"}, | |
// "max_id": []string{"632284973349769216"}, | |
// } | |
// | |
// tweets, err := api.GetUserTimeline(params) | |
// | |
// fmt.Println(tweets) | |
// | |
// if len(tweets) == 0 { | |
// break | |
// } | |
// | |
// if err != nil { | |
// log.Fatal(err) | |
// } | |
// | |
// for i := 0; i < len(tweets); i++ { | |
// go api.DeleteTweet(tweets[i].Id, true) | |
// deleted++ | |
// if deleted%100 == 0 { | |
// fmt.Println("Deleted ", deleted) | |
// } | |
// } | |
// } | |
// } | |
func main() { | |
anaconda.SetConsumerKey("") | |
anaconda.SetConsumerSecret("") | |
api := anaconda.NewTwitterApi("", "") | |
var deleted int64 = 0 | |
tweets_csv, err := os.Open("/Users/tmcw/Downloads/1458271_3a607ccffa9088feecc17ae57bb619277b8beb90/tweets.csv") | |
if err != nil { | |
log.Fatal(err) | |
} | |
r := csv.NewReader(tweets_csv) | |
r.Read() | |
var start_id int64 = 494491108223619072 | |
started := false | |
for { | |
record, err := r.Read() | |
if err == io.EOF { | |
break | |
} | |
if err != nil { | |
log.Fatal(err) | |
} | |
i, err := strconv.ParseInt(record[0], 10, 64) | |
if err != nil { | |
panic(err) | |
} | |
if i == start_id { | |
started = true | |
fmt.Println("started") | |
} | |
if started { | |
_, err = api.DeleteTweet(i, true) | |
if err != nil { | |
} | |
deleted++ | |
if deleted%100 == 0 { | |
fmt.Println("Deleted ", deleted) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment