fix windows quit

This commit is contained in:
eson 2020-08-04 14:12:00 +08:00
parent 93ec2e78a6
commit 826d15876a
3 changed files with 6 additions and 8 deletions

View File

@ -51,7 +51,6 @@ func (cl *ChannelLink) Execute() {
var hrefs map[string]bool = make(map[string]bool)
var delayerror = 5
var samecount = 0
for i := 0; i <= 200; i++ {
cards, err := wd.FindElements(selenium.ByXPATH, "//span/a[contains(@data-a-target,'card-') and @href]")
if err != nil {
@ -59,7 +58,7 @@ func (cl *ChannelLink) Execute() {
break
}
if len(cards) == samecount {
if len(hrefs) == 0 {
delayerror--
if delayerror <= 0 {
break
@ -80,7 +79,7 @@ func (cl *ChannelLink) Execute() {
}
break
}
samecount = len(cards)
if ps.IsClose() {
break
}

View File

@ -29,12 +29,12 @@ func (cl *UserList) Execute() {
//article//a[@data-a-target='preview-card-title-link']
wd := intimate.GetChromeDriver(3030)
defer wd.Quit()
ps := intimate.NewPerfectShutdown()
counter := intimate.NewCounter()
counter.SetMaxLimit(100)
counter.SetMaxToDo(func(olist ...interface{}) error {
owd := olist[0].(*selenium.WebDriver)
(*owd).Close()
(*owd).Quit()
*owd = intimate.GetChromeDriver(3030)
return nil

View File

@ -103,10 +103,9 @@ func GetChromeDriver(port int) selenium.WebDriver {
panic(err)
}
runtime.SetFinalizer(wd, func(obj interface{}) {
if err := obj.(selenium.WebDriver).Close(); err != nil {
log.Println(err)
}
// if err := obj.(selenium.WebDriver).Close(); err != nil {
// log.Println(err)
// }
if err := obj.(selenium.WebDriver).Quit(); err != nil {
log.Println(err)
}