This commit is contained in:
dylan 2022-11-04 18:30:00 +08:00
parent 8ebcd4786d
commit 06acf3c664
1 changed files with 362 additions and 347 deletions

View File

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# 自动带图评价、追评、服务评价需电脑端CK
# @Time : 2022/10/2
# @Time : 2022/11/4
# @Author : @qiu-lzsnmb and @Dimlitter @Dylan
# @File : auto_comment.py
# 多账号评价,异常处理
'''
new Env('自动评价');
8 8 2 10 * https://raw.githubusercontent.com/6dylan6/auto_comment/main/jd_comment.py
@ -35,8 +36,6 @@ except:
from lxml import etree
import requests
import jdspider
@ -165,6 +164,7 @@ def generation(pname, _class=0, _type=1, opts=None):
# 查询全部评价
def all_evaluate(opts=None):
try:
opts = opts or {}
N = {}
url = 'https://club.jd.com/myJdcomments/myJdcomment.action?'
@ -195,9 +195,12 @@ def all_evaluate(opts=None):
num = 0
N[na] = int(num)
return N
except Exception as e:
print (e)
# 评价晒单
def sunbw(N, opts=None):
try:
opts = opts or {}
Order_data = []
req_et = []
@ -339,10 +342,12 @@ def sunbw(N, opts=None):
idx += 1
N['待评价订单'] -= 1
return N
except Exception as e:
print (e)
# 追评
def review(N, opts=None):
try:
opts = opts or {}
req_et = []
Order_data = []
@ -425,10 +430,12 @@ def review(N, opts=None):
time.sleep(REVIEW_SLEEP_SEC)
N['待追评'] -= 1
return N
except Exception as e:
print (e)
# 服务评价
def Service_rating(N, opts=None):
try:
opts = opts or {}
Order_data = []
req_et = []
@ -509,7 +516,8 @@ def Service_rating(N, opts=None):
time.sleep(SERVICE_RATING_SLEEP_SEC)
N['服务评价'] -= 1
return N
except Exception as e:
print (e)
def No(opts=None):
opts = opts or {}
@ -523,7 +531,7 @@ def No(opts=None):
def main(opts=None):
opts = opts or {}
opts['logger'].info("开始京东自动评价!")
#opts['logger'].info("开始京东自动评价!")
N = No(opts)
opts['logger'].debug('N value after executing No(): %s', N)
if not N:
@ -547,7 +555,7 @@ def main(opts=None):
opts['logger'].debug('N value after executing Service_rating(): %s', N)
N = No(opts)
opts['logger'].debug('N value after executing No(): %s', N)
opts['logger'].info("本次运行完成!")
opts['logger'].info("该账号运行完成!")
if __name__ == '__main__':
@ -643,16 +651,23 @@ if __name__ == '__main__':
#print()
#logger.debug('Closed the configuration file')
#logger.debug('Configurations in Python-dict format: %s', cfg)
cks = []
if "PC_COOKIE" in os.environ:
if len(os.environ["PC_COOKIE"]) > 200:
ck = os.environ["PC_COOKIE"]
logger.info ("已获取环境变量 CK")
if '&' in os.environ["PC_COOKIE"]:
cks = os.environ["PC_COOKIE"].split('&')
else:
cks.append(os.environ["PC_COOKIE"])
else:
logger.info ("CK错误请确认是否电脑版CK")
sys.exit(1)
logger.info ("已获取环境变量 CK")
else:
logger.info("没有设置变量PC_COOKIE请添加电脑端CK到环境变量")
sys.exit(1)
try:
i = 1
for ck in cks:
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',
@ -673,10 +688,10 @@ if __name__ == '__main__':
'Accept-Language': 'zh-CN,zh;q=0.9',
}
logger.debug('Builtin HTTP request header: %s', headers)
logger.debug('Starting main processes')
try:
print ('\n开始第 '+ str(i) +'个账号评价。。。\n')
main(opts)
i += 1
# NOTE: It needs 3,000 times to raise this exception. Do you really want to
# do like this?
except RecursionError: