forked from mertensnova/grawddit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (29 loc) · 781 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"flag"
"log"
"time"
"github.com/nyx6965/grawddit/scrape"
)
func main() {
startTime := time.Now()
var subreddit string
var limit int
var category string
flag.StringVar(&subreddit, "subreddit", "TwoSentenceHorror", "Subreddit")
flag.IntVar(&limit, "limit", 10, "Number of posts to scrape")
flag.StringVar(&category, "sort", "top", "Type of sort E.g [new,top,hot]")
flag.Parse()
baseDataDir := "./data"
data, err := scrape.Start(subreddit, limit, category)
if err != nil {
log.Println(err)
}
if err := scrape.WritetoJSON(data, baseDataDir + "/" + subreddit + ".json" ); err != nil {
log.Println(err)
}
endTime := time.Now()
elapsedTime := endTime.Sub(startTime)
log.Println("Done!")
log.Println("Elapsed Time:", elapsedTime)
}