|
@@ -1,66 +0,0 @@
|
1
|
|
-<!DOCTYPE html>
|
2
|
|
-<html lang="en">
|
3
|
|
- <head>
|
4
|
|
- <meta charset="UTF-8" />
|
5
|
|
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
|
- <title>模拟高频请求</title>
|
7
|
|
- </head>
|
8
|
|
- <body>
|
9
|
|
- <script>
|
10
|
|
- function random1() {
|
11
|
|
- return Math.floor(Math.random() * 90000000000) + 1000000000;
|
12
|
|
- }
|
13
|
|
- function random2() {
|
14
|
|
- return Math.ceil(Math.random() * 90000000000) + 1000000000;
|
15
|
|
- }
|
16
|
|
- // 假设我们有一个模拟的API调用函数
|
17
|
|
- function mockApiCall() {
|
18
|
|
- // 在这里,我们只是简单地打印一条消息到控制台,而不是真正发送请求
|
19
|
|
- // 在实际情况下,你可能会使用fetch、axios或其他HTTP库来发送请求
|
20
|
|
- const username = random1();
|
21
|
|
- const password = random2();
|
22
|
|
- const data = new URLSearchParams();
|
23
|
|
- data.append("username", username);
|
24
|
|
- data.append("password", password);
|
25
|
|
- data.append("q_password", password);
|
26
|
|
- data.append("state", 0);
|
27
|
|
- fetch("http://tacpkt.shop/index/login/register", {
|
28
|
|
- method: "POST",
|
29
|
|
- headers: {
|
30
|
|
- Cookie: "think_var=zh-cn",
|
31
|
|
- "X-Requested-With": "XMLHttpRequest",
|
32
|
|
- Origin: "http://tacpkt.shop",
|
33
|
|
- Host: "tacpkt.shop",
|
34
|
|
- },
|
35
|
|
-
|
36
|
|
- body: data,
|
37
|
|
- });
|
38
|
|
- }
|
39
|
|
-
|
40
|
|
-
|
41
|
|
-
|
42
|
|
-
|
43
|
|
- // 例如,我们每秒发送x次请求
|
44
|
|
- const requestsPerSecond = 3;
|
45
|
|
- let counter = 0;
|
46
|
|
-
|
47
|
|
- // 使用setInterval来模拟每秒发送请求
|
48
|
|
- const intervalId = setInterval(() => {
|
49
|
|
- // 每次调用mockApiCall函数,并增加计数器
|
50
|
|
- for (let i = 0; i < requestsPerSecond; i++) {
|
51
|
|
- mockApiCall();
|
52
|
|
- }
|
53
|
|
- // 增加计数器,用于监控已经发送的请求数量
|
54
|
|
- counter += requestsPerSecond;
|
55
|
|
- console.log(`已发送 ${counter} 个请求`);
|
56
|
|
-
|
57
|
|
- // 如果你想要在某个点停止发送请求,可以清除interval
|
58
|
|
- // 例如,当发送了100个请求后停止
|
59
|
|
- if (counter >= 100000000) {
|
60
|
|
- clearInterval(intervalId);
|
61
|
|
- console.log("停止发送请求");
|
62
|
|
- }
|
63
|
|
- }, 1000 / requestsPerSecond); // 调整时间间隔以匹配每秒的请求数
|
64
|
|
- </script>
|
65
|
|
- </body>
|
66
|
|
-</html>
|