部署 12306 github 项目

郑重声明, 本文仅用作学习研究使用,请勿用作商业用途,遵守法律!!!

部署环境有些坑,踩一次就够了。。。

原项目地址

git clone 原项目以及 识别验证码的模型

如果遇到 无法解析的问题 ,则 yum update nss curl

git clone https://github.com/testerSunshine/12306model.git   (我个人也有保存网盘)

git clone https://github.com/testerSunshine/12306.git

安装 requirements.txt


推荐 anaconda 进行包管理, conda  create -n py36 然后 配置一下 环境变量 一顿 安装
/home/ml/anaconda3/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

可能会少一些 模块

pip install opencv-python

下载 chrome 以及 chrome driver

1、安装chrome

用下面的命令安装最新的 Google Chrome

yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
也可以下载到本地再安装
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum install ./google-chrome-stable_current_x86_64.rpm
 

安装必要的库
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
 
还有其他的 谷歌浏览器问题

https://www.e-learn.cn/content/qita/2350043

2、安装 chromedriver

chrome官网 wget https://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip
淘宝源(推荐)wget http://npm.taobao.org/mirrors/chromedriver/2.41/chromedriver_linux64.zip
 

 
将下载的文件解压,放在如下位置

unzip chromedriver_linux64.zip

/usr/bin/chromedriver

给予执行权限

chmod +x /usr/bin/chromedriver

设置 chrome driver 参数信息

grep -r 'webdriver'
vim config/getCookie.py



options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--headless')





 from selenium import webdriver
        cookies = []
        options = webdriver.ChromeOptions()
        options.add_argument('--no-sandbox')
        options.add_argument('--disable-dev-shm-usage')
        options.add_argument('headless')
        driver = webdriver.Chrome(chrome_options=options, executable_path=TickerConfig.CHROME_PATH)
        driver.get("https://www.12306.cn/index/index.html")
其中
“–no-sandbox”参数是让Chrome在root权限下跑
“–headless”参数是不用打开图形界面
可以额外加这些参数获得更好体验

其中
“–no-sandbox”参数是让Chrome在root权限下跑
“–headless”参数是不用打开图形界面
可以额外加这些参数获得更好体验

options.add_argument('blink-settings=imagesEnabled=false')
options.add_argument('--disable-gpu')

同步时间 并 修改时区

sudo ntpdate -u 210.72.145.44

sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime


ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

放置 预测模型文件

cp 12306models/xxx.h5   12306/

原文地址:https://www.cnblogs.com/Frank99/p/11493262.html