forked from Huibq/keep-alive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (44 loc) · 1.81 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import random
import time
import requests
render_url = os.environ['render_url']
zeabur_url = os.environ['zeabur_url']
zeabur_url_key = os.environ['zeabur_url_key']
ua_list = [
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.39',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1788.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1788.0 uacq',
'Mozilla/5.0 (Windows NT 10.0; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5666.197 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 uacq',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
]
def request(uri, head=None):
try:
info = requests.get(uri, headers=head, timeout=6)
return info
except Exception as c:
print(c)
return None
start_time = time.time()
number = 0
while (time.time() - start_time) < 256:
try:
headers = {'User-Agent': random.choice(ua_list)}
req = request(render_url, head=headers)
headers['X-Request-Key'] = zeabur_url_key
req2 = request(zeabur_url, head=headers)
print("----------------")
if req.status_code == 200:
print(req.json()['data'])
number += 1
print(req2.text)
time.sleep(random.randint(45, 90))
else:
print("失败!")
time.sleep(random.randint(15, 48))
number += 1
except Exception as e:
print(e)
time.sleep(50)
number += 1