# -*- coding: utf-8 -*- #通过gradio获取请求 from utils import * from login import get_cookie_alive_str #这里千万不能导入login中的session和header ,否则会错误 import uvicorn from fastapi import FastAPI import gradio as gr app = FastAPI() with gr.Blocks() as getCookieStr: # 获取到返回的结果-可以是上传的,可以是查看files信息,也可以是别的 someResult = gr.Textbox(label="获取按钮返回信息", type="text") get_cookie_btn = gr.Button("获取") # 设置按钮点击事件(获取cookie和响应头截止时间) get_cookie_btn.click(fn=get_cookie_alive_str, inputs=[], outputs=someResult) #挂载cookie获取借口 app = gr.mount_gradio_app(app, getCookieStr, path="/gr") # 通过fid来获取网盘信息->[] 链接+提取码 /None @app.get("/getPanInfo") def getPanInfo(fid:str): session.headers = headers jsonResp = try_puchase(fid=fid, session=session) print(jsonResp) panResult = get_pan_info(fid=fid, session=session) # 每次先尝试购买然后重新打开detail页面查询返回 print(panResult) return panResult if __name__ == '__main__': uvicorn.run(app, host='0.0.0.0', port=7860)