fix windows quit
This commit is contained in:
parent
93ec2e78a6
commit
826d15876a
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
7
utils.go
7
utils.go
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user