Skip to content

Instantly share code, notes, and snippets.

@nicholasserra
Created November 18, 2022 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasserra/14a0a0aabec05b310adcc73aa817f551 to your computer and use it in GitHub Desktop.
Save nicholasserra/14a0a0aabec05b310adcc73aa817f551 to your computer and use it in GitHub Desktop.
package main
import (
"context"
"encoding/json"
"fmt"
twitterscraper "github.com/n0madic/twitter-scraper"
"os"
)
func main() {
user := "splrawiki"
var arr []interface{}
scraper := twitterscraper.New()
for tweet := range scraper.GetTweets(context.Background(), user, 5000) {
if tweet.Error != nil {
panic(tweet.Error)
}
arr = append(arr, tweet)
}
e, _ := json.Marshal(arr)
f, _ := os.Create(user + ".json")
defer f.Close()
f.Write(e)
f.Sync()
arrLength := len(arr)
fmt.Println("Total:", arrLength)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment