Skip to content

Commit

Permalink
运行参数解析遗漏 获取抢购连接也调整为多线程获取
Browse files Browse the repository at this point in the history
  • Loading branch information
zqjzqj committed Jan 7, 2021
1 parent f991b09 commit 3e6a9b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ var num = flag.Int("num", 2, "茅台商品ID")
var works = flag.Int("works", 7, "并发数")
var start = flag.String("time", "09:59:59", "开始时间---不带日期")

func init() {
flag.Parse()
}

func main() {
var err error
execPath := ""
Expand Down
4 changes: 2 additions & 2 deletions secKill/jdSecKill.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ func (jsk *jdSecKill) Run() error {
jsk.WaitStart(),
chromedp.ActionFunc(func(ctx context.Context) error {
//提取抢购连接
jsk.FetchSecKillUrl()
for _, v := range jsk.bWorksCtx {
go func(ctx2 context.Context) {
jsk.FetchSecKillUrl()
SecKillRE:
//请求抢购连接,提交订单
err := jsk.ReqSubmitSecKillOrder(ctx2)
Expand Down Expand Up @@ -328,10 +328,10 @@ func (jsk *jdSecKill) GetEidAndFp() chromedp.ActionFunc {
func (jsk *jdSecKill) FetchSecKillUrl() {
logs.PrintlnInfo("开始获取抢购连接.....")
for {
jsk.SecKillUrl = jsk.GetSecKillUrl()
if jsk.SecKillUrl != "" {
break
}
jsk.SecKillUrl = jsk.GetSecKillUrl()
logs.PrintlnWarning("抢购链接获取失败.....正在重试")
}
jsk.SecKillUrl = "https:" + strings.TrimPrefix(jsk.SecKillUrl, "https:")
Expand Down

0 comments on commit 3e6a9b5

Please sign in to comment.