|
@@ -26,7 +26,7 @@ from common.publish import Publish
|
|
|
from common.scheduling_db import MysqlHelper
|
|
|
|
|
|
|
|
|
-class GongzhonghaoFollow2:
|
|
|
+class GongzhonghaoFollow3:
|
|
|
# 翻页参数
|
|
|
begin = 0
|
|
|
platform = "公众号"
|
|
@@ -73,7 +73,9 @@ class GongzhonghaoFollow2:
|
|
|
continue
|
|
|
token = sheet[0][1]
|
|
|
cookie = sheet[1][1]
|
|
|
- token_dict = {'token': token, 'cookie': cookie}
|
|
|
+ gzh_name = sheet[2][1]
|
|
|
+ gzh_time = sheet[3][1]
|
|
|
+ token_dict = {'token': token, 'cookie': cookie, 'gzh_name': gzh_name, 'gzh_time': gzh_time}
|
|
|
return token_dict
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type, crawler).error(f"get_cookie_token异常:{e}\n")
|
|
@@ -118,22 +120,22 @@ class GongzhonghaoFollow2:
|
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "token_2过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"token_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "公众号_2频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"公众号_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
if "list" not in r.json() or len(r.json()["list"]) == 0:
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).warning(f"get_fakeid:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "公众号_2频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"公众号_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
fakeid = r.json()["list"][int(index) - 1]["fakeid"]
|
|
@@ -241,22 +243,22 @@ class GongzhonghaoFollow2:
|
|
|
if r.json()["base_resp"]["err_msg"] == "invalid session":
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).info(f"get_videoList:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "token_2过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"token_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n过期啦,请扫码更换token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
if r.json()["base_resp"]["err_msg"] == "freq control":
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "公众号_2频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"公众号_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
if 'app_msg_list' not in r.json():
|
|
|
Common.logger(log_type, crawler).info(f"status_code:{r.status_code}")
|
|
|
Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
- if 21 >= datetime.datetime.now().hour >= 10:
|
|
|
- Feishu.bot(log_type, crawler, "公众号_2频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
+ if 20 >= datetime.datetime.now().hour >= 10:
|
|
|
+ Feishu.bot(log_type, crawler, f"公众号_3:{token_dict['gzh_name']}\n更换日期:{token_dict['gzh_time']}\n频控啦,请扫码更换其他公众号token\nhttps://mp.weixin.qq.com/")
|
|
|
time.sleep(60 * 10)
|
|
|
continue
|
|
|
if len(r.json()['app_msg_list']) == 0:
|
|
@@ -328,8 +330,8 @@ class GongzhonghaoFollow2:
|
|
|
return
|
|
|
cls.download_publish(log_type, crawler, video_dict, oss_endpoint, env)
|
|
|
|
|
|
- Common.logger(log_type, crawler).info('随机休眠 0-60 秒\n')
|
|
|
- time.sleep(random.randint(0, 60))
|
|
|
+ Common.logger(log_type, crawler).info('随机休眠 60-60*3 秒\n')
|
|
|
+ time.sleep(random.randint(60, 60*3))
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type, crawler).error("get_videoList异常:{}\n", e)
|
|
|
|
|
@@ -498,14 +500,14 @@ class GongzhonghaoFollow2:
|
|
|
Common.logger(log_type, crawler).info(f'获取 {user_name} 公众号视频\n')
|
|
|
cls.get_videoList(log_type, crawler, user_name, index, oss_endpoint, env)
|
|
|
cls.begin = 0
|
|
|
- Common.logger(log_type, crawler).info('随机休眠 0-60 秒\n')
|
|
|
- time.sleep(random.randint(0, 60))
|
|
|
+ Common.logger(log_type, crawler).info('随机休眠 60-60*3 秒\n')
|
|
|
+ time.sleep(random.randint(60, 60*3))
|
|
|
except Exception as e:
|
|
|
Common.logger(log_type, crawler).info(f'get_all_videos异常:{e}\n')
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
- GongzhonghaoFollow2.get_users()
|
|
|
+ GongzhonghaoFollow3.get_users()
|
|
|
# GongzhonghaoFollow.get_users()
|
|
|
# GongzhonghaoFollow.get_videoList(log_type="follow",
|
|
|
# crawler="gongzhonghao",
|