learn-spider/bin/start_spider.sh

24 lines
550 B
Bash

#!/bin/bash
spider_code=$1
index=$2
PUBLIC_DIR="${2:-/shared}"
export DISPLAY=:$index
echo "当前显示桌面:$DISPLAY"
start_spider(){
echo "正在启动爬虫$spider_code"
if [ "$spider_code" = "01" ]; then
spider_name="china_net.py"
elif [ "$spider_code" = "02" ]; then
spider_name="mail_qq.py"
else
echo "爬虫名称错误"
exit -1
fi
echo "爬虫名称:$spider_name"
.venv/bin/python3.12 "spider/$spider_name"
}
echo "启动爬虫"
cd $PUBLIC_DIR/learn-spider
echo "$PUBLIC_DIR/learn-spider"
start_spider