Skip to content

Commit 227acc5

Browse files
committed
fix
1 parent 210a8dc commit 227acc5

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
cmd/aiqicha/aiqicha
22
cmd/aiqicha/*.xlsx
3+
cmd/aiqicha/*.txt

pkg/aiqicha/search.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ const sleep = async (ms) => {
295295
}
296296
await sleep(2000);
297297
}
298-
await sleep(2000);
299298
}
300299
control()
301300
`
@@ -307,7 +306,7 @@ const sleep = async (ms) => {
307306
return err
308307
}
309308
// 存在多页则等待
310-
result, exception, err = runtime.Evaluate(`document.querySelector('#basic-hold > div > ul > li')`).Do(ctx)
309+
result, exception, err = runtime.Evaluate(`document.querySelector('#basic-hold > div > div > ul > li')`).Do(ctx)
311310
if exception != nil {
312311
err = exception
313312
}
@@ -318,7 +317,7 @@ const sleep = async (ms) => {
318317
if result.ClassName == "HTMLLIElement" {
319318
// 下一页为display: none导致WaitVisible不可用
320319
// REF: https://github.com/chromedp/chromedp/issues/262
321-
return chromedp.WaitReady("#basic-hold > div > ul > li.ivu-page-next.ivu-page-disabled > a > i").Do(ctx)
320+
return chromedp.WaitNotVisible("#basic-hold > div > div > ul > li.ivu-page-next").Do(ctx)
322321
}
323322
return
324323
}),
@@ -375,7 +374,6 @@ const sleep = async (ms) => {
375374
}
376375
await sleep(2000);
377376
}
378-
await sleep(2000);
379377
}
380378
invest()
381379
`
@@ -396,7 +394,7 @@ const sleep = async (ms) => {
396394
}
397395
// 存在: HTMLHeadingElement
398396
if result.ClassName == "HTMLDivElement" {
399-
return chromedp.WaitReady("#basic-invest > div.aqc-table-list-pager > div > ul > li.ivu-page-next.ivu-page-disabled").Do(ctx)
397+
return chromedp.WaitNotVisible("#basic-invest > div.aqc-table-list-pager > div > ul > li.ivu-page-next").Do(ctx)
400398
}
401399
return
402400
}),
@@ -490,7 +488,6 @@ const shareholders = async () => {
490488
}
491489
await sleep(2000);
492490
}
493-
await sleep(2000);
494491
}
495492
shareholders()`
496493
_, exception, err = runtime.Evaluate(auto).Do(ctx)
@@ -501,7 +498,7 @@ shareholders()`
501498
return err
502499
}
503500
// 存在多页则等待
504-
result, exception, err = runtime.Evaluate(`document.querySelector('#basic-shareholders > div.aqc-table-list-pager')`).Do(ctx)
501+
result, exception, err = runtime.Evaluate(`document.querySelector('#basic-shareholders > div.aqc-table-list-pager > div > ul')`).Do(ctx)
505502
if exception != nil {
506503
err = exception
507504
}
@@ -510,7 +507,7 @@ shareholders()`
510507
}
511508
// 存在: HTMLHeadingElement
512509
if result.ClassName == "HTMLDivElement" {
513-
return chromedp.WaitReady("#basic-shareholders > div.aqc-table-list-pager > div > ul > li.ivu-page-next.ivu-page-disabled > a > i").Do(ctx)
510+
return chromedp.WaitNotVisible("#basic-shareholders > div.aqc-table-list-pager > div > ul > li.ivu-page-next").Do(ctx)
514511
}
515512
return
516513
}),
@@ -566,7 +563,6 @@ const webRecord = async () => {
566563
}
567564
await sleep(2000);
568565
}
569-
await sleep(2000);
570566
}
571567
webRecord()`
572568
_, exception, err = runtime.Evaluate(auto).Do(ctx)
@@ -577,7 +573,7 @@ webRecord()`
577573
return err
578574
}
579575
// 存在多页则等待
580-
result, exception, err = runtime.Evaluate(`document.querySelector('#certRecord-webRecord > div.aqc-table-list-pager')`).Do(ctx)
576+
result, exception, err = runtime.Evaluate(`document.querySelector('#certRecord-webRecord > div > div > ul')`).Do(ctx)
581577
if exception != nil {
582578
err = exception
583579
}
@@ -586,11 +582,11 @@ webRecord()`
586582
}
587583
// 存在: HTMLHeadingElement
588584
if result.ClassName == "HTMLDivElement" {
589-
return chromedp.WaitReady("#certRecord-webRecord > div.aqc-table-list-pager > div > ul > li.ivu-page-next.ivu-page-disabled > a > i").Do(ctx)
585+
return chromedp.WaitNotVisible("#certRecord-webRecord > div > div > ul > li.ivu-page-next").Do(ctx)
590586
}
591587
return
592588
}),
593-
chromedp.Sleep(2 * time.Second),
589+
chromedp.Sleep(10 * time.Second),
594590
chromedp.ActionFunc(func(ctx context.Context) error {
595591
return target.CloseTarget(chromedp.FromContext(ctx).Target.TargetID).Do(cdp.WithExecutor(ctx, chromedp.FromContext(ctx).Browser))
596592
}),

0 commit comments

Comments
 (0)