只为便宜一点买微信读书会员.
微信读书规则
根据实际操作, 还有如下未明确说明的特点:
工具特性
Linux
直接运行
下载链接: weread-challenge.js
# 安装 nodejs
sudo apt install nodejs
# 老旧版本的 nodejs 需要安装 npm
sudo apt install npm
# 创建运行文件夹
mkdir -p $HOME/weread-challenge
cd $HOME/weread-challenge
# 安装依赖
npm install selenium-webdriver
# 通过环境变量设置运行参数
WEREAD_BROWSER="chrome"
# 运行
node weread-challenge.js
如需邮件通知, 需安装 nodemailer:
npm install nodemailer
Docker Compose 运行
services:
app:
image: jqknono/weread-challenge:latest
pull_policy: always
environment:
- WEREAD_REMOTE_BROWSER=http://selenium:4444
- WEREAD_DURATION=68
volumes:
- ./data:/app/data
depends_on:
selenium:
condition: service_healthy
selenium:
image: selenium/standalone-chrome:4.26
pull_policy: if_not_present
shm_size: 2gb
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SE_ENABLE_TRACING=false
- SE_BIND_HOST=false
- SE_JAVA_DISABLE_HOSTNAME_VERIFICATION=false
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4444/wd/hub/status"]
interval: 5s
timeout: 60s
retries: 10
保存为 docker-compose.yml, 运行 docker compose up -d.
Docker 运行
# run selenium standalone
docker run --restart always -d --name selenium-live \
-v /var/run/docker.sock:/var/run/docker.sock \
--shm-size="2g" \
-p 4444:4444 \
-p 7900:7900 \
-e SE_ENABLE_TRACING=false \
-e SE_BIND_HOST=false \
-e SE_JAVA_DISABLE_HOSTNAME_VERIFICATION=false \
-e SE_NODE_MAX_INSTANCES=10 \
-e SE_NODE_MAX_SESSIONS=10 \
-e SE_NODE_OVERRIDE_MAX_SESSIONS=true \
selenium/standalone-chrome:4.26
# run weread-challenge
docker run --rm --name user-read \
-v $HOME/weread-challenge/user/data:/app/data \
-e WEREAD_REMOTE_BROWSER=http://172.17.0.2:4444 \
-e WEREAD_DURATION=68 \
weread-challenge:beta
# add another user
docker run --rm --name user2-read \
-v $HOME/weread-challenge/user2/data:/app/data \
-e WEREAD_REMOTE_BROWSER=http://172.17.0.2:4444 \
-e WEREAD_DURATION=68 \
weread-challenge:latest
创建定时任务
docker-compose
WORKDIR=$HOME/weread-challenge
mkdir -p $WORKDIR
cd $WORKDIR
cat > $WORKDIR/docker-compose.yml /dev/null; echo "00 07 * * * cd $WORKDIR && docker compose up -d") | crontab -
docker
# 启动浏览器
docker run --restart always -d --name selenium-live \
-v /var/run/docker.sock:/var/run/docker.sock \
--shm-size="2g" \
-p 4444:4444 \
-p 7900:7900 \
-e SE_ENABLE_TRACING=false \
-e SE_BIND_HOST=false \
-e SE_JAVA_DISABLE_HOSTNAME_VERIFICATION=false \
-e SE_NODE_MAX_INSTANCES=3 \
-e SE_NODE_MAX_SESSIONS=3 \
-e SE_NODE_OVERRIDE_MAX_SESSIONS=true \
-e SE_SESSION_REQUEST_TIMEOUT=10 \
-e SE_SESSION_RETRY_INTERVAL=3 \
selenium/standalone-chrome:4.26
WEREAD_USER="user"
mkdir -p $HOME/weread-challenge/$WEREAD_USER/data
# Get container IP
Selenium_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' selenium-live)
# 首次启动后, 需微信扫描二维码登录, 二维码保存在 $HOME/weread-challenge/$WEREAD_USER/data/login.png
# 每天早上 7 点启动, 阅读 68 分钟
(crontab -l 2>/dev/null; echo "00 07 * * * docker run --rm --name ${WEREAD_USER}-read -v $HOME/weread-challenge/${WEREAD_USER}/data:/app/data -e WEREAD_REMOTE_BROWSER=http://${Selenium_IP}:4444 -e WEREAD_DURATION=68 -e WEREAD_USER=${WEREAD_USER} jqknono/weread-challenge:latest") | crontab -
Windows
# 安装 nodejs
winget install -e --id Node.js.Node.js
# 创建运行文件夹
mkdir -p $HOME/weread-challenge
cd $HOME/weread-challenge
# 安装依赖
npm install selenium-webdriver
# 通过环境变量设置运行参数
$WEREAD_BROWSER="MicrosoftEdge"
# 运行
node weread-challenge.js
Docker 运行同 Linux.
MacOS
# 安装 nodejs
brew install node
# 创建运行文件夹
mkdir -p $HOME/weread-challenge
# 安装依赖
npm install selenium-webdriver
# 通过环境变量设置运行参数
WEREAD_BROWSER="safari"
# 运行
node weread-challenge.js
Docker 运行同 Linux.
多用户支持
# 启动浏览器
docker run --restart always -d --name selenium-live \
-v /var/run/docker.sock:/var/run/docker.sock \
--shm-size="2g" \
-p 4444:4444 \
-p 7900:7900 \
-e SE_ENABLE_TRACING=false \
-e SE_BIND_HOST=false \
-e SE_JAVA_DISABLE_HOSTNAME_VERIFICATION=false \
-e SE_NODE_MAX_INSTANCES=10 \
-e SE_NODE_MAX_SESSIONS=10 \
-e SE_NODE_OVERRIDE_MAX_SESSIONS=true \
selenium/standalone-chrome:4.26
WEREAD_USER1="user1"
WEREAD_USER2="user2"
mkdir -p $HOME/weread-challenge/$WEREAD_USER1/data
mkdir -p $HOME/weread-challenge/$WEREAD_USER2/data
# Get container IP
Selenium_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' selenium-live)
# 首次启动后, 需微信扫描二维码登录, 二维码保存在:
# /$HOME/weread-challenge/${WEREAD_USER1}/data/login.png
# /$HOME/weread-challenge/${WEREAD_USER2}/data/login.png
# 每天早上 7 点启动, 阅读 68 分钟
(crontab -l 2>/dev/null; echo "00 07 * * * docker run --rm --name ${WEREAD_USER1}-read -v $HOME/weread-challenge/${WEREAD_USER1}/data:/app/data -e WEREAD_REMOTE_BROWSER=http://${Selenium_IP}:4444 -e WEREAD_DURATION=68 -e WEREAD_USER=${WEREAD_USER1} jqknono/weread-challenge:latest") | crontab -
(crontab -l 2>/dev/null; echo "00 07 * * * docker run --rm --name ${WEREAD_USER2}-read -v $HOME/weread-challenge/${WEREAD_USER2}/data:/app/data -e WEREAD_REMOTE_BROWSER=http://${Selenium_IP}:4444 -e WEREAD_DURATION=68 -e WEREAD_USER=${WEREAD_USER2} jqknono/weread-challenge:latest") | crontab -
可配置项
[td]环境变量[/td]
[td]默认值[/td]
[td]可选值[/td]
[td]说明[/td]
WEREAD_USER
weread-default
-
用户标识
WEREAD_REMOTE_BROWSER
""
-
远程浏览器地址
WEREAD_DURATION
10
-
阅读时长
WEREAD_SELECTION
random
[0-4]
选择阅读的书籍
WEREAD_BROWSER
chrome
chrome,MicrosoftEdge,firefox,safari
浏览器
ENABLE_EMAIL
false
true,false
邮件通知
EMAIL_SMTP
""
-
邮箱 SMTP 服务器
EMAIL_USER
""
-
邮箱用户名
EMAIL_PASS
""
-
邮箱密码
EMAIL_TO
""
-
收件人
WEREAD_AGREE_TERMS
true
true,false
隐私同意条款
容器多架构支持
支持 linux/amd64,linux/arm64, 支持树莓派等开发板.
docker buildx create --name weread-challenge
docker buildx use weread-challenge
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 -t jqknono/weread-challenge:base -f Dockerfile.base --push .
docker buildx build --platform linux/amd64,linux/arm64 -t jqknono/weread-challenge:latest -f Dockerfile.quick --push .
注意事项
隐私政策
隐私获取
风险提示
参考