nimo 插件优化

nimo 数据测试提取成功
This commit is contained in:
eson 2020-09-02 18:56:20 +08:00
parent a72ba6257c
commit 3b7e8e94ea
11 changed files with 2162 additions and 28 deletions

Binary file not shown.

View File

@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY----- -----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSG09DSvB03TOe MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDA6O6owySvzaJ8
eOmQwfiCIf0wa2WRB31ewxa6i/PRgEKeJSUvIsIuaECUer2ss+J3rwSS2lDpGuiw iv6aXRMcuk0lnNKquPNVHeraadSkBVhtaJqPAT7saOVnn9g4s/21OBV6wGmWdl5W
FnsVyZqKI/+Rcuc83YJGYg6OAzVMz6UL8YCWhXu3huTJ+V+a5iNereIC69ZERRJt 5+8h+F4qXrlGO8N1Tl8mmBDetqg6T6RrI9vB2Th9hjlp2PCGCEg/lX+tx25qBiDG
nXlWqsq6HKya+6BP9sX9CI4GTHQrnWBysAxsswhdnnnRvu+GxglWafSIzuS6OizT 9uCB3pU4KMyfof1Z2jbo7aOfttgxZ1YdssenB//+31QjeZVw7wZACKaSzl6Z+WvY
1M1CmkZxNvDJhTSOR7SJlIYm2kM5/fIL53BdndF2IGAjfV1WV7AjwhTfun5cViEO pastMZ95YgTQvUq1AP93ny8AG+/bKUlE2vZpDygUJAXT8R7PGVD6T0/hUjTZk9HM
i8niQUIMY4L0AiO9grFD1g1xIYkeuVBoLxOUBzPxJwQmb64gseb9Dvt0BKLRGoou hrLShNjsBMxWWsrc7rdfW+R44pSuw5kHtIBrjRdrr8m1W0BCGTlGjq7Sk0OOZbsO
SIOyE+KVAgMBAAECggEAI4b6J2kR0VUBEDwmVHO0K38HUstqNHSVgrNO0dLt8sAz sh7x/1kvAgMBAAECggEAQYFXOTs6g/AB0uSn2+brDIA+nh0IdCxlhGuqSgxRxniC
I44o5DhGqPW4a9L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HdqmPT4pScPLZvj+6c3iX8D8wzhzbgZtS0I
dilCHUoO33rafXJy6jtaggtpz14tt9soecTop0vM/rU7tGtfBe6NXg9LRl+oDJCU h+r1yMEdzyRZMGtvdi/f/+1TuhOTr/ZeoqYHWEduo8iRYLQBN9gGEkkKBQ4d14zi
37I3a9Is+2CLyAUXWCk9mLfFsQ== 8elaha7vrG/teCrFoeFcXIPr
-----END PRIVATE KEY----- -----END PRIVATE KEY-----

View File

@ -0,0 +1,9 @@
package main
import "intimate"
// sstore 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
var sstore *intimate.StoreSource = intimate.NewStoreSource(string(intimate.STNimo))
// estore 解析存储连接实例
var estore *intimate.StoreExtractor = intimate.NewStoreExtractor()

View File

@ -0,0 +1,88 @@
package main
import (
"intimate"
"log"
"testing"
"time"
"github.com/474420502/extractor"
"github.com/tebeka/selenium"
)
func TestMain(t *testing.T) {
Execute()
}
type WaitFor struct {
WebDriver selenium.WebDriver
}
func NewWaitFor(wd selenium.WebDriver) *WaitFor {
return &WaitFor{WebDriver: wd}
}
func (wf *WaitFor) Default(xpath string, do func(elements ...selenium.WebElement) bool) error {
return wf.WebDriver.WaitWithTimeout(func(wd selenium.WebDriver) (bool, error) {
elements, err := wd.FindElements(selenium.ByXPATH, xpath)
if err != nil {
log.Println(err)
return false, err
}
if len(elements) > 0 {
if do == nil {
return true, nil
}
if do(elements...) {
return true, nil
}
}
return false, nil
}, time.Second*15)
}
type LiveInfo struct {
Followers int64 `exp:"//div[contains(@class,'nimo-rm_followers')]//span[@class='text c2']" mth:"r:ExtractNumber"`
Views int64 `exp:"//div[contains(@class,'nimo-rm_audience')]//span[@class='text c2']" mth:"r:ExtractNumber"`
Giver []int64 `exp:"//div[contains(@class,'rank-item-after3')]//span[contains(@class,'nimo-currency__count')]"`
}
func Execute() {
wd := intimate.GetChromeDriver(3031)
waitfor := NewWaitFor(wd)
ps := intimate.NewPerfectShutdown()
for !ps.IsClose() {
// streamer, err := estore.Pop(intimate.PNimo)
// if err != nil {
// log.Println(err)
// // estore.UpdateError(streamer, err)
// continue
// }
// log.Println(streamer)
var pagesource string
// wd.Get(streamer.LiveUrl.String)
wd.Get("https://www.nimo.tv/live/1253835677")
waitfor.Default("//div[contains(@class,'nimo-rm_followers')]//span[@class='text c2' and text() != '']", nil)
waitfor.Default("//div[contains(@class,'rank-item-top3')]", nil)
element, err := wd.FindElement(selenium.ByXPATH, "//div[contains(@class,'rank-item-top3')]")
if err != nil {
log.Println(err)
} else {
err = element.MoveTo(50, 50)
element.Click()
if err != nil {
log.Println(err)
}
}
waitfor.Default("//div[contains(@class,'nimo-rm_audience')]//span[@class='text c2']", nil)
pagesource, _ = wd.PageSource()
etor := extractor.ExtractHtmlString(pagesource)
li := etor.GetObjectByTag(LiveInfo{}).(*LiveInfo)
log.Printf("%#v", li)
}
}

View File

@ -29,7 +29,7 @@ func main() {
// var err error // var err error
for !ps.IsClose() { for !ps.IsClose() {
streamer, err := estore.PopNoWait(intimate.Ptwitch, "tags is NULL", 15) streamer, err := estore.Pop(intimate.Ptwitch)
if streamer == nil || err != nil { if streamer == nil || err != nil {
if err != lasterr { if err != lasterr {
log.Println(err, lasterr) log.Println(err, lasterr)

View File

@ -228,6 +228,7 @@ func NewStoreExtractor() *StoreExtractor {
return &StoreExtractor{db: db} return &StoreExtractor{db: db}
} }
// PopNoWait 弹出一个不用按时间间隔更新的主播信息, 主要用来测试.
func (store *StoreExtractor) PopNoWait(platform Platform, condition string, operators ...int32) (*Streamer, error) { func (store *StoreExtractor) PopNoWait(platform Platform, condition string, operators ...int32) (*Streamer, error) {
tx, err := store.db.Begin() tx, err := store.db.Begin()
if err != nil { if err != nil {

View File

@ -0,0 +1,13 @@
[supervisord]
nodaemon=false
[program:nimo_task1]
environment=DISPLAY=":99"
directory = MYPATH/bin/nimo_task1/
command= MYPATH/bin/nimo_task1/nimo_task1
# process_name=%(program_name)s_%(process_num)02d ;多进程名称
# numprocs=1 ;启动多个进程
autorestart=true
stderr_logfile=MYPATH/bin/nimo_task1/log
stderr_logfile_maxbytes=0
stopsignal=QUIT

View File

@ -0,0 +1,5 @@
package main
func main() {
Execute()
}

View File

@ -59,7 +59,7 @@ func Execute() {
log.Println(tp.GetURLRawPath(), "rooms:", len(rooms)) log.Println(tp.GetURLRawPath(), "rooms:", len(rooms))
if len(rooms) == 0 { if len(rooms) == 0 {
param.IntSet(1) param.IntSet(1)
time.Sleep(time.Minute * 10) time.Sleep(time.Minute * 15)
continue continue
} }

2015
testfile/nimolive.html Normal file

File diff suppressed because one or more lines are too long

View File

@ -87,9 +87,12 @@ func GetChromeDriver(port int) selenium.WebDriver {
caps := selenium.Capabilities{"browserName": "chrome"} caps := selenium.Capabilities{"browserName": "chrome"}
chromecaps := chrome.Capabilities{} chromecaps := chrome.Capabilities{}
// chromecaps.AddExtension("/home/eson/test/myblock.crx")
for _, epath := range []string{"../../../crx/myblock.crx", "../../crx/myblock.crx"} { for _, epath := range []string{"../../../crx/myblock.crx", "../../crx/myblock.crx"} {
_, err := os.Stat(epath) _, err := os.Stat(epath)
if err == nil { if err == nil {
err := chromecaps.AddExtension(epath) err := chromecaps.AddExtension(epath)
if err != nil { if err != nil {
panic(err) panic(err)