5912111f29
add: Channel tag
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"intimate"
|
|
"log"
|
|
"testing"
|
|
|
|
"github.com/474420502/extractor"
|
|
"github.com/tebeka/selenium"
|
|
)
|
|
|
|
func TestMain(t *testing.T) {
|
|
Execute()
|
|
}
|
|
|
|
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"`
|
|
Channel string `exp:"//div[contains(@class,'nimo-rm_type')]//span"`
|
|
Giver []int64 `exp:"//div[contains(@class,'rank-item-after3')]//span[contains(@class,'nimo-currency__count')]"`
|
|
}
|
|
|
|
func Execute() {
|
|
wd := intimate.GetChromeDriver(3031)
|
|
waitfor := intimate.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)
|
|
}
|
|
}
|