完成twitch的期望功能

This commit is contained in:
eson
2020-07-31 18:04:10 +08:00
parent ac1ab81676
commit 0c54cbf8d8
13 changed files with 334 additions and 100 deletions

View File

@@ -25,7 +25,7 @@ type ChannelLink struct {
func (cl *ChannelLink) Execute() {
var err error
wd := intimate.GetChromeDriver(3030)
defer wd.Close()
ps := intimate.NewPerfectShutdown()
weburl := "https://www.twitch.tv/directory?sort=VIEWER_COUNT"
err = wd.Get(weburl)
@@ -40,7 +40,7 @@ func (cl *ChannelLink) Execute() {
}
return len(elements) > 0, nil
}
wd.WaitWithTimeout(cardCondition, time.Second*30)
wd.WaitWithTimeout(cardCondition, time.Second*15)
time.Sleep(time.Second)
e, err := wd.FindElement(selenium.ByXPATH, "//button[@data-a-target='browse-sort-menu']")
@@ -68,15 +68,22 @@ func (cl *ChannelLink) Execute() {
delayerror = 5
}
for _, card := range cards {
href, err := card.GetAttribute("href")
if err != nil {
log.Println(err)
} else {
hrefs[href] = true
for ii := 0; ii < 10; ii++ {
for _, card := range cards {
href, err := card.GetAttribute("href")
if err != nil {
log.Println(href, err)
continue
} else {
hrefs[href] = true
}
}
break
}
samecount = len(cards)
if ps.IsClose() {
break
}
if len(cards) > 10 {
log.Println(len(cards))
@@ -88,7 +95,6 @@ func (cl *ChannelLink) Execute() {
time.Sleep(time.Millisecond * 200)
wd.KeyUp(selenium.EndKey)
time.Sleep(time.Millisecond * 2500)
}
for href := range hrefs {