Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

网页中的js被设置了4s后才运行 #9

Open
zhangyc310 opened this issue Sep 16, 2019 · 1 comment
Open

网页中的js被设置了4s后才运行 #9

zhangyc310 opened this issue Sep 16, 2019 · 1 comment

Comments

@zhangyc310
Copy link

大侠,surfer非常好,非常有用
但也遇到一个问题:
网页中的js通过setTimeout设置了4s后才运行,请问如何让停止4s以自动运行网页里面的js?

@zhangyc310
Copy link
Author

surf.go文件202行左右位置添加了time.Sleep(5 * time.Second),还是不行

if param.TryTimes <= 0 {
		for {
			resp, err = param.client.Do(req)
			if err != nil {
				if !param.EnableCookie {
					l := len(UserAgents["common"])
					r := rand.New(rand.NewSource(time.Now().UnixNano()))
					req.Header.Set("User-Agent", UserAgents["common"][r.Intn(l)])
				}
				time.Sleep(param.RetryPause)
				param.renewBody()
				continue
			}
			time.Sleep(5 * time.Second)
			log.Println("成功获取网页,等待几秒钟:")
			break
		}
	} else {
		for i := 0; i < param.TryTimes; i++ {
			if i != 0 {
				time.Sleep(param.RetryPause)
				param.renewBody()
			}
			resp, err = param.client.Do(req)
			if err != nil {
				if !param.EnableCookie {
					l := len(UserAgents["common"])
					r := rand.New(rand.NewSource(time.Now().UnixNano()))
					req.Header.Set("User-Agent", UserAgents["common"][r.Intn(l)])
				}
				continue
			}

			log.Println("成功获取网页xxxx,等待几秒钟:", param.RetryPause)
			log.Println("成功获取网页xxxx,等待几秒钟:=====", resp)
			time.Sleep(5 * time.Second)
			break
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant