Skip to content

Commit 7ff3ac6

Browse files
liubotesterSunshine
authored andcommitted
新增了基于Python3.7的Dockerfile
1 parent 39e777e commit 7ff3ac6

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

Dockerfile37

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM python:3.7
2+
3+
ARG CDV=77.0.3865.40
4+
5+
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
6+
echo 'deb http://mirrors.163.com/debian/ jessie main non-free contrib' > /etc/apt/sources.list && \
7+
echo 'deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib' >> /etc/apt/sources.list && \
8+
echo 'deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib' >> /etc/apt/sources.list
9+
10+
RUN apt-get -y update
11+
12+
ADD . /usr/src/app
13+
WORKDIR /usr/src/app
14+
15+
RUN wget -c https://dl.lancdn.com/landian/soft/chrome/m/77.0.3865.120_amd64.deb && \
16+
apt-get install -y adwaita-icon-theme at-spi2-core dbus dconf-gsettings-backend dconf-service fonts-liberation glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas libappindicator3-1 libasound2 libasound2-data libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcolord2 libcups2 libdbus-1-3 libdbusmenu-glib4 libdbusmenu-gtk3-4 libdconf1 libdrm2 libfile-basedir-perl libfile-desktopentry-perl libfile-mimeinfo-perl libfontenc1 libgl1-mesa-glx libglapi-mesa libgnutls-deb0-28 libgtk-3-0 libgtk-3-bin libgtk-3-common libhogweed2 libindicator3-7 libjson-glib-1.0-0 libjson-glib-1.0-common libnettle4 libnspr4 libnss3 libproxy1 librest-0.7-0 libsoup-gnome2.4-1 libsoup2.4-1 libwayland-client0 libwayland-cursor0 libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-shape0 libxcb-sync1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxmu6 libxmuu1 libxpm4 libxrandr2 libxshmfence1 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 multiarch-support x11-utils x11-xserver-utils xdg-utils xkb-data libgconf2-4 lsb-release && \
17+
dpkg -i 77.0.3865.120_amd64.deb && \
18+
wget -c http://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE
19+
20+
21+
RUN wget -c https://npm.taobao.org/mirrors/chromedriver/$CDV/chromedriver_linux64.zip && \
22+
apt-get install -y unzip && \
23+
unzip chromedriver_linux64.zip
24+
25+
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider --no-cache-dir -r requirements.txt
26+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
27+
28+
29+
30+
31+
32+
33+
34+
ENV DEBIAN_FRONTEND noninteractive
35+
ENV TZ Asia/Shanghai
36+
37+
38+
## install python requirements
39+
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider --no-cache-dir -r requirements.txt
40+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
41+
42+
## install ntpdate, not accept but saving code
43+
#RUN echo 'deb http://mirrors.163.com/debian/ jessie main non-free contrib \
44+
# deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib \
45+
# deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib' > /etc/apt/sources.list \
46+
# && apt-get update\
47+
# && apt-get install ntpdate -y \
48+
49+
50+
#EXPOSE 5010
51+
52+
CMD [ "python", "run.py" ]
53+
#ENTRYPOINT [ "python", "run.py" ]

TickerConfig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
# chromedriver配置版本只要和chrome的大版本匹配就行
122122
CHROME_PATH = "/Users/wenxianping/Downloads/chromedriver"
123123

124+
#为了docker37 准备的环境变量,windows环境可以不用管这个参数
125+
CHROME_CHROME_PATH = "/usr/src/app/google-chrome";
126+
124127
# 如果COOKIE_TYPE=3, 则需配置RAIL_EXPIRATION、RAIL_DEVICEID的值
125128
RAIL_EXPIRATION = ""
126129
RAIL_DEVICEID = ""

config/getCookie.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import random
33
import re
44
import time
5+
import os
56
import TickerConfig
67
from config.urlConf import urls
78

@@ -14,7 +15,14 @@ def getDrvicesID(session):
1415
if TickerConfig.COOKIE_TYPE is 1:
1516
from selenium import webdriver
1617
cookies = []
17-
driver = webdriver.Chrome(executable_path=TickerConfig.CHROME_PATH)
18+
# 解决放镜像里 DevToolsActivePort file doesn't exist的问题
19+
options = webdriver.ChromeOptions()
20+
if os.name != 'nt' and TickerConfig.CHROME_CHROME_PATH:
21+
options = webdriver.ChromeOptions()
22+
options.binary_location = TickerConfig.CHROME_CHROME_PATH
23+
options.add_argument("--no-sandbox")
24+
options.add_argument("--headless")
25+
driver = webdriver.Chrome(executable_path=TickerConfig.CHROME_PATH,chrome_options=options)
1826
driver.get("https://www.12306.cn/index/index.html")
1927
time.sleep(10)
2028
for c in driver.get_cookies():

0 commit comments

Comments
 (0)