添加获取CNB网址的工具函数,更新主程序以打印运行网址,新增requirements.txt文件,优化前端页面布局和样式,增加移动端菜单功能。
This commit is contained in:
@ -1,21 +1,27 @@
|
||||
import requests
|
||||
import time
|
||||
|
||||
s = requests.Session()
|
||||
s.headers = {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://b.quark.cn',
|
||||
'Referer': 'https://b.quark.cn/',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; U; Android 15; zh-CN; 2312DRA50C Build/AQ3A.240912.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.80 Quark/7.9.2.771 Mobile Safari/537.36',
|
||||
'X-Requested-With': 'com.quark.browser',
|
||||
'sec-ch-ua': '"Android WebView";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
|
||||
'sec-ch-ua-mobile': '?1',
|
||||
'sec-ch-ua-platform': '"Android"'
|
||||
}
|
||||
|
||||
|
||||
|
||||
def login_quark(token):
|
||||
"""
|
||||
夸克登录
|
||||
:param token: 登录token
|
||||
:return: 是否登录成功
|
||||
"""
|
||||
s = requests.Session()
|
||||
s.headers = {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Origin': 'https://b.quark.cn',
|
||||
'Referer': 'https://b.quark.cn/',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; U; Android 15; zh-CN; 2312DRA50C Build/AQ3A.240912.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.80 Quark/7.9.2.771 Mobile Safari/537.36',
|
||||
'X-Requested-With': 'com.quark.browser',
|
||||
'sec-ch-ua': '"Android WebView";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
|
||||
'sec-ch-ua-mobile': '?1',
|
||||
'sec-ch-ua-platform': '"Android"'
|
||||
}
|
||||
sign_wg = "AAQHaE4ww2nnIPvofH2SfMv3N6OplcPRjxlgScTZozm/ZCMfQP74bsMLyKW883hZCGY=";
|
||||
kps_wg = "AARWcp9UM71t5VzV9i5pBJ4dLXjJ7EZL5a9qz2QVVQtkkmcqS4wQGYtk38CRzW6HH4+5c7qsB9/EtUgkWcd8x/k7h9+PmAHUDvxKHUWnX7iL3h2fH86XJ4cEqwvUnQ77QGs=";
|
||||
vcode = int(time.time() * 1000) # 相当于JavaScript中的Date.now(),返回当前时间的毫秒数
|
||||
|
22
utils/tools.py
Normal file
22
utils/tools.py
Normal file
@ -0,0 +1,22 @@
|
||||
import requests
|
||||
import time
|
||||
import re
|
||||
|
||||
s = requests.Session()
|
||||
|
||||
def get_cnb_weburl(port):
|
||||
s.headers= {"Authorization": "2hk178fffIx8tdXLD9YjYJot0gA"}
|
||||
|
||||
res = s.get("https://api.cnb.cool/workspace/list?branch=main&status=running").json()
|
||||
info = res["list"][0]
|
||||
urlinfo = s.get(f"https://api.cnb.cool/{info['slug']}/-/workspace/detail/{info['sn']}").json()
|
||||
|
||||
#re提取cnb-id
|
||||
pattern = r'cnb-[a-z0-9]+-[a-z0-9]+-\d+'
|
||||
match = re.search(pattern, urlinfo["webide"])
|
||||
if match:
|
||||
cnb_id = match.group(0)
|
||||
else:
|
||||
cnb_id = None
|
||||
|
||||
return f"https://{cnb_id}-{port}.cnb.run/"
|
Reference in New Issue
Block a user