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"
|
VNC_SERVER_HOST = "https://10.10.40.19:6080"
|
||||||
SHELL_DIR = "/home/dgs/vnc-server"
|
SHELL_DIR = "/home/dgs/vnc-server"
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def mail_qq_spider(account: str) -> str:
|
async def mail_qq_spider(account: str,display: int) -> str:
|
||||||
"""qq邮箱爬虫,第一个参数是用户名"""
|
"""qq邮箱爬虫,第一个参数是用户名
|
||||||
result = await asyncio.to_thread(a1, account)
|
Args:
|
||||||
|
account: qq邮箱用户名
|
||||||
|
display: 显示桌面编号
|
||||||
|
Returns:
|
||||||
|
str: 爬虫结果
|
||||||
|
"""
|
||||||
|
result = await asyncio.to_thread(a1, account, display)
|
||||||
return result
|
return result
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def start_vnc_server(display: int) -> str:
|
async def start_vnc_server(display: int) -> str:
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,10 @@ def extract_cookies_from_auth(auth_file):
|
||||||
return cookies
|
return cookies
|
||||||
|
|
||||||
|
|
||||||
def crawl_with_saved_state(auth_file):
|
def crawl_with_saved_state(auth_file,display=0):
|
||||||
with sync_playwright() as p:
|
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)
|
context = browser.new_context(storage_state=auth_file)
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto('https://mail.qq.com')
|
page.goto('https://mail.qq.com')
|
||||||
|
|
@ -105,7 +105,7 @@ def crawl_with_saved_state(auth_file):
|
||||||
|
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
||||||
def start(account):
|
def start(account, display=0):
|
||||||
print(f"用户名{account}")
|
print(f"用户名{account}")
|
||||||
if not account:
|
if not account:
|
||||||
print("请输入用户名")
|
print("请输入用户名")
|
||||||
|
|
@ -113,7 +113,7 @@ def start(account):
|
||||||
auth_file_path = "./auth/mail"
|
auth_file_path = "./auth/mail"
|
||||||
file_path = f"{auth_file_path}/{account}.json"
|
file_path = f"{auth_file_path}/{account}.json"
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
crawl_with_saved_state(file_path)
|
crawl_with_saved_state(file_path, display)
|
||||||
else:
|
else:
|
||||||
save_login_state(file_path,"收件箱")
|
save_login_state(file_path, "收件箱")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue