39 lines
728 B
Go
Raw Normal View History

2018-03-08 18:54:08 +00:00
package main
import (
2018-03-08 19:07:03 +00:00
"fmt"
2018-03-08 18:54:08 +00:00
"time"
2018-03-08 19:07:03 +00:00
"github.com/animenotifier/arn"
"github.com/fatih/color"
2018-03-08 18:54:08 +00:00
"github.com/aerogo/crawler"
)
const userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.166 Safari/537.36"
func main() {
2018-03-08 19:07:03 +00:00
defer arn.Node.Close()
2018-03-08 18:54:08 +00:00
malCrawler := crawler.New(userAgent, 1*time.Second, 20000)
2018-03-08 19:07:03 +00:00
count := 0
for anime := range arn.StreamAnime() {
malID := anime.GetMapping("myanimelist/anime")
if malID == "" {
continue
}
malCrawler.Queue(&crawler.Task{
URL: "https://myanimelist.net/anime/" + malID,
Destination: fmt.Sprintf("mal/anime-%s.html", malID),
})
2018-03-08 18:54:08 +00:00
2018-03-08 19:07:03 +00:00
count++
}
2018-03-08 18:54:08 +00:00
2018-03-08 19:07:03 +00:00
color.Yellow("Queued up %d links", count)
2018-03-08 18:54:08 +00:00
malCrawler.Wait()
}