wangkun před 2 roky
rodič
revize
e7e3842c31
2 změnil soubory, kde provedl 11 přidání a 5 odebrání
  1. 8 2
      main/gzh.py
  2. 3 3
      main/run_gzh.py

+ 8 - 2
main/gzh.py

@@ -149,7 +149,7 @@ class GZH:
                     "accept-language": "zh-CN,zh;q=0.9",
                     "referer": "https://mp.weixin.qq.com/cgi-bin/appmsg?"
                                "t=media/appmsg_edit_v2&action=edit&isNew=1"
-                               "&type=77&createType=5&token=1011071554&lang=zh_CN",
+                               "&type=77&createType=5&token="+str(cls.get_cookie_token(log_type, "token"))+"&lang=zh_CN",
                     'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
                     "sec-ch-ua-mobile": "?0",
                     "sec-ch-ua-platform": '"Windows"',
@@ -168,7 +168,7 @@ class GZH:
                     "fakeid": userid,
                     "type": "9",
                     "query": "",
-                    "token": cls.get_cookie_token(log_type, "token"),
+                    "token": str(cls.get_cookie_token(log_type, "token")),
                     "lang": "zh_CN",
                     "f": "json",
                     "ajax": "1",
@@ -178,6 +178,8 @@ class GZH:
                 cls.begin += 5
                 if 'app_msg_list' not in r.json() or len(r.json()['app_msg_list']) == 0:
                     Common.logger(log_type).warning("get_gzh_url:response:{}\n", r.text)
+                    Common.logger(log_type).info('休眠 1 分钟')
+                    time.sleep(60 * 1)
                     break
                 else:
                     app_msg_list = r.json()['app_msg_list']
@@ -273,6 +275,8 @@ class GZH:
                                 Common.logger(log_type).info("当前用户已抓取:{}条数据\n", len(cls.gzh_count))
                                 cls.gzh_count = []
                                 return
+
+                time.sleep(60*1)
             except Exception as e:
                 Common.logger(log_type).error("get_gzh_url异常:{}\n", e)
 
@@ -287,6 +291,8 @@ class GZH:
                 head_url = user_sheet[i][3]
                 Common.logger(log_type).info("获取 {} 公众号文章\n", username)
                 cls.get_gzh_url(log_type, username, userid, head_url)
+                Common.logger(log_type).info("休眠 10 分钟")
+                time.sleep(60*10)
         except Exception as e:
             Common.logger(log_type).error("get_all_gzh异常:{}\n", e)
 

+ 3 - 3
main/run_gzh.py

@@ -15,9 +15,9 @@ class Main:
     def main(cls, env):
         while True:
             if 18 >= datetime.datetime.now().hour >= 8:
-                # 获取用户及 ID 信息
-                Common.logger('gzh').info("今日公众号抓取任务开始\n")
-                GZH.search_user_by_word('gzh')
+                # # 获取用户及 ID 信息
+                # Common.logger('gzh').info("今日公众号抓取任务开始\n")
+                # GZH.search_user_by_word('gzh')
                 # 获取所有用户的公众号文章信息
                 Common.logger('gzh').info("获取用户文章信息\n")
                 GZH.get_all_gzh('gzh')