使用playwright代替akshare爬指数数据
This commit is contained in:
@@ -3,6 +3,41 @@ FROM python:3.12-slim
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
wget \
|
||||
gnupg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装Playwright的依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libnss3 \
|
||||
libnspr4 \
|
||||
libatk1.0-0 \
|
||||
libatk-bridge2.0-0 \
|
||||
libcups2 \
|
||||
libdrm2 \
|
||||
libdbus-1-3 \
|
||||
libxkbcommon0 \
|
||||
libxcomposite1 \
|
||||
libxdamage1 \
|
||||
libxfixes3 \
|
||||
libxrandr2 \
|
||||
libgbm1 \
|
||||
libasound2 \
|
||||
libpango-1.0-0 \
|
||||
libpangocairo-1.0-0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 配置pip源
|
||||
RUN mkdir -p /root/.pip && \
|
||||
echo "[global]" > /root/.pip/pip.conf && \
|
||||
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
|
||||
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf
|
||||
|
||||
# 更新pip
|
||||
RUN python -m pip install --upgrade pip
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
@@ -10,7 +45,7 @@ RUN apt-get update && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install uv \
|
||||
&& rm -rf /root/.cache/pip
|
||||
&& rm -rf /root/.cache/pip
|
||||
|
||||
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
@@ -23,6 +58,16 @@ COPY requirements.txt .
|
||||
|
||||
RUN uv pip install --system -r requirements.txt
|
||||
|
||||
# 预先安装 Playwright 的系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
xvfb \
|
||||
libopengl0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装Playwright浏览器
|
||||
RUN playwright install chromium
|
||||
RUN playwright install-deps
|
||||
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 80
|
||||
|
||||
Reference in New Issue
Block a user