|
1 |
| -// 伪造IP |
2 | 1 |
|
3 |
| -//浏览器库 |
4 |
| -// const userAgents = [ |
5 |
| -// 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12', |
6 |
| -// 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)', |
7 |
| -// 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11', |
8 |
| -// 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20', |
9 |
| -// 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6', |
10 |
| -// 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.71 Safari/537.1 LBBROWSER', |
11 |
| -// 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0) ,Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9', |
12 |
| -// 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)', |
13 |
| -// 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)', |
14 |
| -// 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)', |
15 |
| -// 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b13pre) Gecko/20110307 Firefox/4.0b13pre', |
16 |
| -// 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52', |
17 |
| -// 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12', |
18 |
| -// 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; LBBROWSER)', |
19 |
| -// 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6', |
20 |
| -// 'Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6', |
21 |
| -// 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)', |
22 |
| -// 'Opera/9.25 (Windows NT 5.1; U; en), Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9', |
23 |
| -// 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36', |
24 |
| -// ]; |
25 |
| -//构造请求头-浏览器 |
26 |
| -function randomHead() { |
27 |
| - return 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'; |
28 |
| -} |
29 |
| -//构造请求头-ip |
30 |
| -function returnIp() { |
31 |
| - return ( |
32 |
| - Math.floor(Math.random() * (10 - 255) + 255) + |
33 |
| - '.' + |
34 |
| - Math.floor(Math.random() * (10 - 255) + 255) + |
35 |
| - '.' + |
36 |
| - Math.floor(Math.random() * (10 - 255) + 255) + |
37 |
| - '.' + |
38 |
| - Math.floor(Math.random() * (10 - 255) + 255) |
39 |
| - ); |
40 |
| -} |
41 |
| - |
42 |
| -// 每100次请求,更换一次ip |
43 |
| -let count = 100; |
44 |
| -const Max = 100; |
45 | 2 | /**
|
46 |
| - * 获取请求 |
| 3 | + * 设置请求头 |
47 | 4 | */
|
48 |
| -export function requestHandle(request) { |
49 |
| - if (count > Max) { |
50 |
| - request.set('User-Agent', randomHead()).set('X-Forwarded-For', returnIp()); |
51 |
| - count = 0; |
52 |
| - } |
53 |
| - count++; |
54 |
| - return request; |
| 5 | +export function getHeader() { |
| 6 | + return { |
| 7 | + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36', |
| 8 | + // 'X-Forwarded-For': returnIp(), |
| 9 | + }; |
55 | 10 | }
|
0 commit comments