|
@@ -53,6 +53,7 @@ class GongzhonghaoAuthor1:
|
|
user_sheet = Feishu.get_values_batch(log_type, crawler, sheetid)
|
|
user_sheet = Feishu.get_values_batch(log_type, crawler, sheetid)
|
|
if user_sheet is None:
|
|
if user_sheet is None:
|
|
Common.logger(log_type, crawler).warning(f"user_sheet:{user_sheet}, 2秒后重试")
|
|
Common.logger(log_type, crawler).warning(f"user_sheet:{user_sheet}, 2秒后重试")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"user_sheet:{user_sheet}, 2秒后重试")
|
|
time.sleep(2)
|
|
time.sleep(2)
|
|
continue
|
|
continue
|
|
user_list = []
|
|
user_list = []
|
|
@@ -66,6 +67,7 @@ class GongzhonghaoAuthor1:
|
|
if wechat_name is None or wechat_name.strip() == "" or wechat_name.replace(" ", "") == "":
|
|
if wechat_name is None or wechat_name.strip() == "" or wechat_name.replace(" ", "") == "":
|
|
wechat_name = user_name
|
|
wechat_name = user_name
|
|
Common.logger(log_type, crawler).info(f"befor_wechat_name:{type(wechat_name)}, {wechat_name}")
|
|
Common.logger(log_type, crawler).info(f"befor_wechat_name:{type(wechat_name)}, {wechat_name}")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"befor_wechat_name:{type(wechat_name)}, {wechat_name}")
|
|
our_uid = user_sheet[i][5]
|
|
our_uid = user_sheet[i][5]
|
|
our_user_link = user_sheet[i][6]
|
|
our_user_link = user_sheet[i][6]
|
|
user_info_dict = cls.get_user_info(log_type=log_type, crawler=crawler, wechat_name=wechat_name, env=env)
|
|
user_info_dict = cls.get_user_info(log_type=log_type, crawler=crawler, wechat_name=wechat_name, env=env)
|
|
@@ -78,6 +80,7 @@ class GongzhonghaoAuthor1:
|
|
tag5 = user_sheet[i][11]
|
|
tag5 = user_sheet[i][11]
|
|
tag6 = user_sheet[i][12]
|
|
tag6 = user_sheet[i][12]
|
|
Common.logger(log_type, crawler).info(f"正在更新 {user_name} 用户信息")
|
|
Common.logger(log_type, crawler).info(f"正在更新 {user_name} 用户信息")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"正在更新 {user_name} 用户信息")
|
|
if out_uid is None or our_uid is None:
|
|
if out_uid is None or our_uid is None:
|
|
# 用来创建our_id的信息
|
|
# 用来创建our_id的信息
|
|
user_dict = {
|
|
user_dict = {
|
|
@@ -89,6 +92,7 @@ class GongzhonghaoAuthor1:
|
|
}
|
|
}
|
|
our_uid = getUser.create_uid(log_type, crawler, user_dict, env)
|
|
our_uid = getUser.create_uid(log_type, crawler, user_dict, env)
|
|
Common.logger(log_type, crawler).info(f'新创建的站内UID:{our_uid}')
|
|
Common.logger(log_type, crawler).info(f'新创建的站内UID:{our_uid}')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'新创建的站内UID:{our_uid}')
|
|
if env == 'prod':
|
|
if env == 'prod':
|
|
our_user_link = f'https://admin.piaoquantv.com/ums/user/{our_uid}/post'
|
|
our_user_link = f'https://admin.piaoquantv.com/ums/user/{our_uid}/post'
|
|
else:
|
|
else:
|
|
@@ -96,8 +100,10 @@ class GongzhonghaoAuthor1:
|
|
Feishu.update_values(log_type, crawler, "Bzv72P", f'D{i + 1}:G{i + 1}', [
|
|
Feishu.update_values(log_type, crawler, "Bzv72P", f'D{i + 1}:G{i + 1}', [
|
|
[user_info_dict["user_id"], user_info_dict["avatar_url"], our_uid, our_user_link]])
|
|
[user_info_dict["user_id"], user_info_dict["avatar_url"], our_uid, our_user_link]])
|
|
Common.logger(log_type, crawler).info(f'用户信息创建成功!\n')
|
|
Common.logger(log_type, crawler).info(f'用户信息创建成功!\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'用户信息创建成功!\n')
|
|
else:
|
|
else:
|
|
Common.logger(log_type, crawler).info("用户信息已存在\n")
|
|
Common.logger(log_type, crawler).info("用户信息已存在\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "用户信息已存在\n")
|
|
our_user_dict = {
|
|
our_user_dict = {
|
|
'user_name': user_name,
|
|
'user_name': user_name,
|
|
'user_id': out_uid,
|
|
'user_id': out_uid,
|
|
@@ -113,6 +119,7 @@ class GongzhonghaoAuthor1:
|
|
@classmethod
|
|
@classmethod
|
|
def get_user_info(cls, log_type, crawler, wechat_name, env):
|
|
def get_user_info(cls, log_type, crawler, wechat_name, env):
|
|
Common.logger(log_type, crawler).info(f"wechat_name:{wechat_name}")
|
|
Common.logger(log_type, crawler).info(f"wechat_name:{wechat_name}")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"wechat_name:{wechat_name}")
|
|
while True:
|
|
while True:
|
|
token_dict = cls.get_token(log_type, crawler, env)
|
|
token_dict = cls.get_token(log_type, crawler, env)
|
|
url = "https://mp.weixin.qq.com/cgi-bin/searchbiz?"
|
|
url = "https://mp.weixin.qq.com/cgi-bin/searchbiz?"
|
|
@@ -148,22 +155,22 @@ class GongzhonghaoAuthor1:
|
|
r = requests.get(url=url, headers=headers, params=params, verify=False)
|
|
r = requests.get(url=url, headers=headers, params=params, verify=False)
|
|
r.close()
|
|
r.close()
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
continue
|
|
continue
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
continue
|
|
continue
|
|
if "list" not in r.json() or len(r.json()["list"]) == 0:
|
|
if "list" not in r.json() or len(r.json()["list"]) == 0:
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_fakeid:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
@@ -262,28 +269,29 @@ class GongzhonghaoAuthor1:
|
|
r = requests.get(url=url, headers=headers, params=params, verify=False)
|
|
r = requests.get(url=url, headers=headers, params=params, verify=False)
|
|
r.close()
|
|
r.close()
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
continue
|
|
continue
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler,f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler,f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']} \n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
continue
|
|
continue
|
|
if 'app_msg_list' not in r.json():
|
|
if 'app_msg_list' not in r.json():
|
|
- Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}")
|
|
|
|
- Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
|
|
|
+ Common.logger(log_type, crawler).warning(f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"status_code:{r.status_code}, get_videoList:{r.text}\n")
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
if 20 >= datetime.datetime.now().hour >= 10:
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
Feishu.bot(log_type, crawler, f"{token_dict['title']}\n操作人:{token_dict['operator']}\n更换日期:{token_dict['update_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
time.sleep(60 * 10)
|
|
time.sleep(60 * 10)
|
|
continue
|
|
continue
|
|
if len(r.json()['app_msg_list']) == 0:
|
|
if len(r.json()['app_msg_list']) == 0:
|
|
Common.logger(log_type, crawler).info('没有更多视频了\n')
|
|
Common.logger(log_type, crawler).info('没有更多视频了\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, "没有更多视频了\n")
|
|
return
|
|
return
|
|
else:
|
|
else:
|
|
begin += 5
|
|
begin += 5
|
|
@@ -313,13 +321,16 @@ class GongzhonghaoAuthor1:
|
|
}
|
|
}
|
|
for k, v in video_dict.items():
|
|
for k, v in video_dict.items():
|
|
Common.logger(log_type, crawler).info(f"{k}:{v}")
|
|
Common.logger(log_type, crawler).info(f"{k}:{v}")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"video_dict:{video_dict}")
|
|
|
|
|
|
if int(time.time()) - publish_time_stamp > 3600 * 24 * int(rule_dict.get('period', {}).get('max', 1000)):
|
|
if int(time.time()) - publish_time_stamp > 3600 * 24 * int(rule_dict.get('period', {}).get('max', 1000)):
|
|
Common.logger(log_type, crawler).info(f"发布时间超过{int(rule_dict.get('period', {}).get('max', 1000))}天\n")
|
|
Common.logger(log_type, crawler).info(f"发布时间超过{int(rule_dict.get('period', {}).get('max', 1000))}天\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"发布时间超过{int(rule_dict.get('period', {}).get('max', 1000))}天\n")
|
|
return
|
|
return
|
|
|
|
|
|
if video_dict['article_url'] == 0 or video_dict['video_url'] == 0:
|
|
if video_dict['article_url'] == 0 or video_dict['video_url'] == 0:
|
|
Common.logger(log_type, crawler).info("文章涉嫌违反相关法律法规和政策\n")
|
|
Common.logger(log_type, crawler).info("文章涉嫌违反相关法律法规和政策\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "文章涉嫌违反相关法律法规和政策\n")
|
|
# 标题敏感词过滤
|
|
# 标题敏感词过滤
|
|
elif any(str(word) if str(word) in video_dict['video_title'] else False
|
|
elif any(str(word) if str(word) in video_dict['video_title'] else False
|
|
for word in get_config_from_mysql(log_type=log_type,
|
|
for word in get_config_from_mysql(log_type=log_type,
|
|
@@ -328,12 +339,15 @@ class GongzhonghaoAuthor1:
|
|
text="filter",
|
|
text="filter",
|
|
action="")) is True:
|
|
action="")) is True:
|
|
Common.logger(log_type, crawler).info("标题已中过滤词\n")
|
|
Common.logger(log_type, crawler).info("标题已中过滤词\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "标题已中过滤词\n")
|
|
# 已下载判断
|
|
# 已下载判断
|
|
elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env) != 0:
|
|
elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env) != 0:
|
|
Common.logger(log_type, crawler).info("视频已下载\n")
|
|
Common.logger(log_type, crawler).info("视频已下载\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "视频已下载\n")
|
|
# 标题相似度
|
|
# 标题相似度
|
|
elif title_like(log_type, crawler, video_dict['video_title'], cls.platform, env) is True:
|
|
elif title_like(log_type, crawler, video_dict['video_title'], cls.platform, env) is True:
|
|
Common.logger(log_type, crawler).info(f'标题相似度>=80%:{video_dict["video_title"]}\n')
|
|
Common.logger(log_type, crawler).info(f'标题相似度>=80%:{video_dict["video_title"]}\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'标题相似度>=80%:{video_dict["video_title"]}\n')
|
|
else:
|
|
else:
|
|
cls.download_publish(log_type=log_type,
|
|
cls.download_publish(log_type=log_type,
|
|
crawler=crawler,
|
|
crawler=crawler,
|
|
@@ -343,7 +357,9 @@ class GongzhonghaoAuthor1:
|
|
env=env)
|
|
env=env)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Common.logger(log_type, crawler).error(f"抓取单条视频异常:{e}\n")
|
|
Common.logger(log_type, crawler).error(f"抓取单条视频异常:{e}\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"抓取单条视频异常:{e}\n")
|
|
Common.logger(log_type, crawler).info('休眠 60 秒\n')
|
|
Common.logger(log_type, crawler).info('休眠 60 秒\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, '休眠 60 秒\n')
|
|
time.sleep(60)
|
|
time.sleep(60)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -363,11 +379,13 @@ class GongzhonghaoAuthor1:
|
|
# 删除视频文件夹
|
|
# 删除视频文件夹
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
|
|
Common.logger(log_type, crawler).info("视频size=0,删除成功\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "视频size=0,删除成功\n")
|
|
return
|
|
return
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
# 删除视频文件夹
|
|
# 删除视频文件夹
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
Common.logger(log_type, crawler).info("视频文件不存在,删除文件夹成功\n")
|
|
Common.logger(log_type, crawler).info("视频文件不存在,删除文件夹成功\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "视频文件不存在,删除文件夹成功\n")
|
|
return
|
|
return
|
|
# 获取视频时长
|
|
# 获取视频时长
|
|
ffmpeg_dict = Common.ffmpeg(log_type, crawler, f"./{crawler}/videos/{video_dict['video_title']}/video.mp4")
|
|
ffmpeg_dict = Common.ffmpeg(log_type, crawler, f"./{crawler}/videos/{video_dict['video_title']}/video.mp4")
|
|
@@ -375,11 +393,15 @@ class GongzhonghaoAuthor1:
|
|
video_dict["video_height"] = ffmpeg_dict["height"]
|
|
video_dict["video_height"] = ffmpeg_dict["height"]
|
|
video_dict["duration"] = ffmpeg_dict["duration"]
|
|
video_dict["duration"] = ffmpeg_dict["duration"]
|
|
Common.logger(log_type, crawler).info(f'video_width:{video_dict["video_width"]}')
|
|
Common.logger(log_type, crawler).info(f'video_width:{video_dict["video_width"]}')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'video_width:{video_dict["video_width"]}')
|
|
Common.logger(log_type, crawler).info(f'video_height:{video_dict["video_height"]}')
|
|
Common.logger(log_type, crawler).info(f'video_height:{video_dict["video_height"]}')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'video_height:{video_dict["video_height"]}')
|
|
Common.logger(log_type, crawler).info(f'duration:{video_dict["duration"]}')
|
|
Common.logger(log_type, crawler).info(f'duration:{video_dict["duration"]}')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'duration:{video_dict["duration"]}')
|
|
if download_rule(log_type, crawler, video_dict, rule_dict) is False:
|
|
if download_rule(log_type, crawler, video_dict, rule_dict) is False:
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
shutil.rmtree(f"./{crawler}/videos/{md_title}")
|
|
Common.logger(log_type, crawler).info("不满足抓取规则,删除成功\n")
|
|
Common.logger(log_type, crawler).info("不满足抓取规则,删除成功\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, "不满足抓取规则,删除成功\n")
|
|
return
|
|
return
|
|
# 下载封面
|
|
# 下载封面
|
|
Common.download_method(log_type=log_type, crawler=crawler, text="cover",
|
|
Common.download_method(log_type=log_type, crawler=crawler, text="cover",
|
|
@@ -389,6 +411,7 @@ class GongzhonghaoAuthor1:
|
|
|
|
|
|
# 上传视频
|
|
# 上传视频
|
|
Common.logger(log_type, crawler).info("开始上传视频...")
|
|
Common.logger(log_type, crawler).info("开始上传视频...")
|
|
|
|
+ Common.logging(log_type, crawler, env, "开始上传视频...")
|
|
strategy = "定向榜爬虫策略"
|
|
strategy = "定向榜爬虫策略"
|
|
if env == 'prod':
|
|
if env == 'prod':
|
|
oss_endpoint = "inner"
|
|
oss_endpoint = "inner"
|
|
@@ -446,8 +469,10 @@ class GongzhonghaoAuthor1:
|
|
{int(video_dict['video_width'])},
|
|
{int(video_dict['video_width'])},
|
|
{int(video_dict['video_height'])}) """
|
|
{int(video_dict['video_height'])}) """
|
|
Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
|
|
Common.logger(log_type, crawler).info(f"insert_sql:{insert_sql}")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"insert_sql:{insert_sql}")
|
|
MysqlHelper.update_values(log_type, crawler, insert_sql, env)
|
|
MysqlHelper.update_values(log_type, crawler, insert_sql, env)
|
|
Common.logger(log_type, crawler).info('视频信息写入数据库成功')
|
|
Common.logger(log_type, crawler).info('视频信息写入数据库成功')
|
|
|
|
+ Common.logging(log_type, crawler, env, '视频信息写入数据库成功')
|
|
|
|
|
|
# 视频写入飞书
|
|
# 视频写入飞书
|
|
Feishu.insert_columns(log_type, crawler, "47e39d", "ROWS", 1, 2)
|
|
Feishu.insert_columns(log_type, crawler, "47e39d", "ROWS", 1, 2)
|
|
@@ -470,31 +495,32 @@ class GongzhonghaoAuthor1:
|
|
time.sleep(0.5)
|
|
time.sleep(0.5)
|
|
Feishu.update_values(log_type, crawler, "47e39d", "F2:Z2", values)
|
|
Feishu.update_values(log_type, crawler, "47e39d", "F2:Z2", values)
|
|
Common.logger(log_type, crawler).info('视频下载/上传成功\n')
|
|
Common.logger(log_type, crawler).info('视频下载/上传成功\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, '视频下载/上传成功\n')
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def get_all_videos(cls, log_type, crawler, rule_dict, env):
|
|
def get_all_videos(cls, log_type, crawler, rule_dict, env):
|
|
user_list = cls.get_users(log_type, crawler, "Bzv72P", env)
|
|
user_list = cls.get_users(log_type, crawler, "Bzv72P", env)
|
|
if user_list is None or len(user_list) == 0:
|
|
if user_list is None or len(user_list) == 0:
|
|
Common.logger(log_type, crawler).warning(f"抓取用户列表为空\n")
|
|
Common.logger(log_type, crawler).warning(f"抓取用户列表为空\n")
|
|
|
|
+ Common.logging(log_type, crawler, env, f"抓取用户列表为空\n")
|
|
return
|
|
return
|
|
for user_dict in user_list:
|
|
for user_dict in user_list:
|
|
try:
|
|
try:
|
|
Common.logger(log_type, crawler).info(f'获取 {user_dict["user_name"]} 公众号视频\n')
|
|
Common.logger(log_type, crawler).info(f'获取 {user_dict["user_name"]} 公众号视频\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'获取 {user_dict["user_name"]} 公众号视频\n')
|
|
cls.get_videoList(log_type=log_type,
|
|
cls.get_videoList(log_type=log_type,
|
|
crawler=crawler,
|
|
crawler=crawler,
|
|
rule_dict=rule_dict,
|
|
rule_dict=rule_dict,
|
|
user_dict=user_dict,
|
|
user_dict=user_dict,
|
|
env=env)
|
|
env=env)
|
|
Common.logger(log_type, crawler).info('休眠 60 秒\n')
|
|
Common.logger(log_type, crawler).info('休眠 60 秒\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, '休眠 60 秒\n')
|
|
time.sleep(60)
|
|
time.sleep(60)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
Common.logger(log_type, crawler).info(f'抓取{user_dict["user_name"]}公众号时异常:{e}\n')
|
|
Common.logger(log_type, crawler).info(f'抓取{user_dict["user_name"]}公众号时异常:{e}\n')
|
|
|
|
+ Common.logging(log_type, crawler, env, f'抓取{user_dict["user_name"]}公众号时异常:{e}\n')
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
- # GongzhonghaoAuthor1.get_token("author", "gongzhonghao", "prod")
|
|
|
|
- # print(GongzhonghaoAuthor1.get_users("author", "gongzhonghao", "Bzv72P", "dev"))
|
|
|
|
- # print(get_config_from_mysql("author", "gongzhonghao", "dev", "filter", action=""))
|
|
|
|
- # print(title_like("author", "gongzhonghao", "公众号", "123", "dev"))
|
|
|
|
print(GongzhonghaoAuthor1.get_user_info("author", "gongzhonghao", "幸福花朵", "dev"))
|
|
print(GongzhonghaoAuthor1.get_user_info("author", "gongzhonghao", "幸福花朵", "dev"))
|
|
pass
|
|
pass
|