From 84ae29117db9ce3397b187e8326079c4d61f803b Mon Sep 17 00:00:00 2001 From: dylan <58234511@qq.com> Date: Sun, 2 Oct 2022 20:03:52 +0800 Subject: [PATCH] 1 --- jd_comment.py | 13 ++++++++----- jd_pjdeps.py | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 jd_pjdeps.py diff --git a/jd_comment.py b/jd_comment.py index fc7ac2e..4691b21 100644 --- a/jd_comment.py +++ b/jd_comment.py @@ -14,22 +14,25 @@ import os import random import sys import time -import requests + try: import jieba # just for linting import jieba.analyse + #import yaml from lxml import etree except: + print('解决依赖问题...稍等') os.system('pip3 install lxml &> /dev/null') os.system('pip3 install jieba &> /dev/null') os.system('pip3 install zhon &> /dev/null') + os.system('pip3 install requests &> /dev/null') import jieba import jieba.analyse #import yaml from lxml import etree - + import requests @@ -620,9 +623,9 @@ if __name__ == '__main__': if len(os.environ["PC_COOKIE"]) > 1: ck = os.environ["PC_COOKIE"] logger.info ("已获取环境变量 CK") - else: - logger.info("请添加电脑端CK变量PC_COOKIE") - sys.exit(1) + else: + logger.info("没有设置变量PC_COOKIE,请添加电脑端CK到环境变量") + sys.exit(1) headers = { 'cookie': ck.encode("utf-8"), 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36', diff --git a/jd_pjdeps.py b/jd_pjdeps.py new file mode 100644 index 0000000..93ce5d4 --- /dev/null +++ b/jd_pjdeps.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +''' +new Env('评价依赖安装'); +8 8 2 10 * https://raw.githubusercontent.com/6dylan6/auto_comment/main/jd_pjdeps.py +''' + +import os +from time import sleep +print('第一次运行评价出错才运行此程序,如果没有问题请勿运行,以免弄出问题!!!') +print('10s后开始安装依赖......') +sleep(10) +os.system('apk add --no-cache libxml2-dev libxslt-dev') +os.system('pip install -U --force-reinstall pip') +os.system('pip3 install lxml') \ No newline at end of file