Add fetcher, support for downloading forum pages
This commit is contained in:
39
domains/fetcher/v1/parser.go
Normal file
39
domains/fetcher/v1/parser.go
Normal file
@@ -0,0 +1,39 @@
|
||||
// NNM-Club torrent filess mass downloader
|
||||
// Created for Uploaders group
|
||||
// Copyright (c) 2012-2019 Vladimir "fat0troll" Hodakov
|
||||
|
||||
package fetcherv1
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
// checkLoginness checks if downloaded page belongs to user
|
||||
func checkLoginness(querier *goquery.Document) bool {
|
||||
authorized := false
|
||||
querier.Find(".mainmenu").Each(func(i int, sel *goquery.Selection) {
|
||||
if strings.Contains(sel.Text(), "Выход") {
|
||||
if strings.Contains(sel.Text(), c.Config.Username) {
|
||||
authorized = true
|
||||
}
|
||||
}
|
||||
})
|
||||
return authorized
|
||||
}
|
||||
|
||||
func getForumName(querier *goquery.Document) string {
|
||||
return querier.Find("h1").First().Text()
|
||||
}
|
||||
|
||||
func getNavigation(querier *goquery.Document) {
|
||||
querier.Find("td[align=right] .nav a").Each(func(i int, sel *goquery.Selection) {
|
||||
if !strings.Contains(sel.Text(), "След") {
|
||||
href, _ := sel.Attr("href")
|
||||
forumPagesLinks[sel.Text()] = href
|
||||
}
|
||||
})
|
||||
|
||||
dlog.Info().Int("количество страниц", len(forumPagesLinks)+1).Msg("Определено количество страниц")
|
||||
}
|
Reference in New Issue
Block a user