diff --git a/.inscode b/.inscode index 8ae4373c1ff5ab4ecc49e3074a6e1ee1f383ad5f..be42c1f8cfd07780db48f93f51b4d7e841dd9610 100644 --- a/.inscode +++ b/.inscode @@ -4,6 +4,6 @@ run = "bash install.sh" VIRTUAL_ENV = "/root/${PROJECT_DIR}/venv" PATH = "${VIRTUAL_ENV}/bin:${PATH}" PYTHONPATH = "$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages" -REPLIT_POETRY_PYPI_REPOSITORY = "http://mirrors.csdn.net.cn/repository/csdn-pypi-mirrors/simple" +REPLIT_POETRY_PYPI_REPOSITORY = " https://pypi.tuna.tsinghua.edu.cn/simple " MPLBACKEND = "TkAgg" POETRY_CACHE_DIR = "/root/${PROJECT_DIR}/.cache/pypoetry" \ No newline at end of file diff --git a/install.sh b/install.sh index 8ae1670dcf157916c9d3dd2468dcfdbec3705188..588e66f4547fa12f812396323622a26ea8523a3b 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ wget 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb' dpkg -i google-chrome-stable_current_amd64.deb apt --fix-broken install -y dpkg -i google-chrome-stable_current_amd64.deb -pip install -r requirements.txt +pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple mkdir -p /usr/share/fonts/chinese/ #创建中文字体目录 cp simsun.ttf /usr/share/fonts/chinese/ #将字体文件拷贝到/usr/share/fonts/chinese/中 diff --git a/main.py b/main.py index 24a6273f62d32c5e37919f2ecb5729a3e3605ccf..88f51d792ee405d97969d88b7b0a8fef8f550d53 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,10 @@ from flask import Flask, render_template, request, send_from_directory from selenium import webdriver from flask import Flask, render_template, request, send_file, jsonify -import os +# import os app = Flask(__name__) app.config['UPLOAD_FOLDER'] = 'static/uploads/' -import time +# import time def take_screenshot(url): # 创建 Chrome 浏览器对象 @@ -19,9 +19,9 @@ def take_screenshot(url): driver.maximize_window() driver.get(url) - time.sleep(5) + # time.sleep(5) driver.implicitly_wait(10) - file_name = os.path.join(app.config['UPLOAD_FOLDER'], f'{os.urandom(8).hex()}.png') + file_name = 'static/uploads/screenshot.png' driver.save_screenshot(file_name) driver.quit() # # 裁剪图片