update start.sh
This commit is contained in:
parent
3b4b96fa1f
commit
fc8ab52858
12
app.py
12
app.py
|
|
@ -12,9 +12,15 @@ logging.info("服务器启动")
|
|||
VNC_SERVER_HOST = "https://10.10.40.19:6080"
|
||||
SHELL_DIR = "/home/dgs/vnc-server"
|
||||
@mcp.tool()
|
||||
async def mail_qq_spider(account: str) -> str:
|
||||
"""qq邮箱爬虫,第一个参数是用户名"""
|
||||
result = await asyncio.to_thread(a1, account)
|
||||
async def mail_qq_spider(account: str,display: int) -> str:
|
||||
"""qq邮箱爬虫,第一个参数是用户名
|
||||
Args:
|
||||
account: qq邮箱用户名
|
||||
display: 显示桌面编号
|
||||
Returns:
|
||||
str: 爬虫结果
|
||||
"""
|
||||
result = await asyncio.to_thread(a1, account, display)
|
||||
return result
|
||||
@mcp.tool()
|
||||
async def start_vnc_server(display: int) -> str:
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ def extract_cookies_from_auth(auth_file):
|
|||
return cookies
|
||||
|
||||
|
||||
def crawl_with_saved_state(auth_file):
|
||||
def crawl_with_saved_state(auth_file,display=0):
|
||||
with sync_playwright() as p:
|
||||
# 加载之前保存的登录状态
|
||||
browser = p.chromium.launch(headless=False) # 可以无头模式了
|
||||
browser = p.chromium.launch(headless=False,env={'DISPLAY': display}) # 可以无头模式了
|
||||
context = browser.new_context(storage_state=auth_file)
|
||||
page = context.new_page()
|
||||
page.goto('https://mail.qq.com')
|
||||
|
|
@ -105,7 +105,7 @@ def crawl_with_saved_state(auth_file):
|
|||
|
||||
browser.close()
|
||||
|
||||
def start(account):
|
||||
def start(account, display=0):
|
||||
print(f"用户名{account}")
|
||||
if not account:
|
||||
print("请输入用户名")
|
||||
|
|
@ -113,7 +113,7 @@ def start(account):
|
|||
auth_file_path = "./auth/mail"
|
||||
file_path = f"{auth_file_path}/{account}.json"
|
||||
if os.path.exists(file_path):
|
||||
crawl_with_saved_state(file_path)
|
||||
crawl_with_saved_state(file_path, display)
|
||||
else:
|
||||
save_login_state(file_path,"收件箱")
|
||||
save_login_state(file_path, "收件箱")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue