|
@@ -24,13 +24,13 @@ class Test:
|
|
:return: search_key, openid
|
|
:return: search_key, openid
|
|
"""
|
|
"""
|
|
try:
|
|
try:
|
|
- while True:
|
|
|
|
- sheet = Feishu.get_values_batch(log_type, crawler, 'sVL74k')
|
|
|
|
- if sheet is None:
|
|
|
|
- Common.logger(log_type, crawler).warning(f"获取热词sheet:{sheet} ,10秒钟后重试")
|
|
|
|
- time.sleep(10)
|
|
|
|
- else:
|
|
|
|
- break
|
|
|
|
|
|
+ # while True:
|
|
|
|
+ sheet = Feishu.get_values_batch(log_type, crawler, 'sVL74k')
|
|
|
|
+ # if sheet is None:
|
|
|
|
+ # Common.logger(log_type, crawler).warning(f"获取热词sheet:{sheet} ,10秒钟后重试")
|
|
|
|
+ # time.sleep(10)
|
|
|
|
+ # else:
|
|
|
|
+ # break
|
|
for i in range(len(sheet)):
|
|
for i in range(len(sheet)):
|
|
search_key = sheet[1][1]
|
|
search_key = sheet[1][1]
|
|
openid = sheet[1][2]
|
|
openid = sheet[1][2]
|
|
@@ -61,9 +61,6 @@ class Test:
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def get_score_test(cls, log_type, crawler):
|
|
def get_score_test(cls, log_type, crawler):
|
|
- wechat_key = cls.get_wechat_key(log_type, crawler)
|
|
|
|
- search_key = wechat_key[0]
|
|
|
|
- openid = wechat_key[-1]
|
|
|
|
|
|
|
|
start_ymd = (date.today() + timedelta(days=-7)).strftime("%Y%m%d")
|
|
start_ymd = (date.today() + timedelta(days=-7)).strftime("%Y%m%d")
|
|
end_ymd = (date.today() + timedelta(days=0)).strftime("%Y%m%d")
|
|
end_ymd = (date.today() + timedelta(days=0)).strftime("%Y%m%d")
|
|
@@ -71,6 +68,17 @@ class Test:
|
|
word_list = cls.get_words(log_type, crawler)
|
|
word_list = cls.get_words(log_type, crawler)
|
|
for i in range(len(word_list)):
|
|
for i in range(len(word_list)):
|
|
Common.logger(log_type, crawler).info(f"热词: {word_list[i]}")
|
|
Common.logger(log_type, crawler).info(f"热词: {word_list[i]}")
|
|
|
|
+ while True:
|
|
|
|
+ wechat_key = cls.get_wechat_key(log_type, crawler)
|
|
|
|
+ if wechat_key is None:
|
|
|
|
+ Common.logger(log_type, crawler).info(
|
|
|
|
+ f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} auth 过期,休眠 10 秒,重新获取")
|
|
|
|
+ time.sleep(10)
|
|
|
|
+ else:
|
|
|
|
+ search_key = wechat_key[0]
|
|
|
|
+ openid = wechat_key[-1]
|
|
|
|
+ break
|
|
|
|
+
|
|
url = "https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex"
|
|
url = "https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex"
|
|
payload = json.dumps({
|
|
payload = json.dumps({
|
|
"openid": openid,
|
|
"openid": openid,
|
|
@@ -93,11 +101,11 @@ class Test:
|
|
"word": word_list[i],
|
|
"word": word_list[i],
|
|
"wechatScores": wechat_score_list,
|
|
"wechatScores": wechat_score_list,
|
|
}
|
|
}
|
|
- if response.json()['code'] == -10000:
|
|
|
|
- Common.logger(log_type, crawler).info(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} response:{response.json()['msg']} 休眠 10 秒,重新获取")
|
|
|
|
- time.sleep(10)
|
|
|
|
- cls.get_score_test(log_type, crawler)
|
|
|
|
- elif response.json()['code'] == -10002:
|
|
|
|
|
|
+ # if response.json()['code'] == -10000:
|
|
|
|
+ # Common.logger(log_type, crawler).info(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time.time())))} response:{response.json()['msg']} 休眠 10 秒,重新获取")
|
|
|
|
+ # time.sleep(10)
|
|
|
|
+ # cls.get_score_test(log_type, crawler)
|
|
|
|
+ if response.json()['code'] == -10002:
|
|
Common.logger(log_type, crawler).info("该词暂未收录")
|
|
Common.logger(log_type, crawler).info("该词暂未收录")
|
|
# 写飞书
|
|
# 写飞书
|
|
if word_list[i] in [x for y in Feishu.get_values_batch(log_type, crawler, "5011a2") for x in y]:
|
|
if word_list[i] in [x for y in Feishu.get_values_batch(log_type, crawler, "5011a2") for x in y]:
|