todo: openrec 重构

This commit is contained in:
eson
2020-08-14 19:26:03 +08:00
parent b20f97f7c9
commit a50c879d83
6 changed files with 25 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import (
"strings"
"time"
"github.com/474420502/extractor"
"github.com/tidwall/gjson"
)
@@ -23,6 +24,12 @@ type OpenrecExtractor struct {
supporters *intimate.ExtractorSource
}
type UserInfo struct {
UserName string `exp:"//p[ contains(@class, 'c-global__user__profile__list__name__text')]"`
Followers int `exp:"//p[@class='c-global__user__count__row__right js-userCountFollowers']" mth:"r:ParseNumber"`
Views int `exp:"//ul[@class='c-contents']//p[@class='c-thumbnailVideo__footer__liveCount']" mth:"r:ExtractNumber"`
}
func (oe *OpenrecExtractor) Execute() {
ps := intimate.NewPerfectShutdown()
@@ -55,6 +62,9 @@ func (oe *OpenrecExtractor) Execute() {
oe.user = intimate.NewExtractorSource(&htmlUser)
oe.user.CreateExtractor()
userEtor := extractor.ExtractHtmlString(htmlUser.String())
log.Println(userEtor.GetObjectByTag(UserInfo{}))
htmlLive := datamap["html_live"]
oe.userLive = intimate.NewExtractorSource(&htmlLive)
oe.userLive.CreateExtractor()