浏览代码

auto publish toutiao articles

luojunhui 5 月之前
父节点
当前提交
66b56d4768
共有 1 个文件被更改,包括 12 次插入3 次删除
  1. 12 3
      tasks/update_published_articles_read_detail.py

+ 12 - 3
tasks/update_published_articles_read_detail.py

@@ -245,6 +245,15 @@ class UpdatePublishedArticlesReadDetail(object):
         gh_id = account_info['ghId']
         latest_update_time = self.get_account_info(gh_id)
         response = spider.update_msg_list(ghId=gh_id, index=cursor)
+        if not response:
+            log(
+                task="updatePublishedMsgDaily",
+                function="update_account_by_spider",
+                status="fail",
+                message="账号更新请求爬虫接口失败",
+                data=account_info
+            )
+            return
         msg_list = response.get("data", {}).get("data", [])
         if msg_list:
             # do
@@ -401,7 +410,7 @@ class UpdatePublishedArticlesReadDetail(object):
         select_sql = f"""
             SELECT push_type
             FROM long_articles_published_trace_id
-            WHERE gh_id = '{gh_id}' AND publish_timestamp > UNIX_TIMESTAMP(CURDATE());
+            WHERE gh_id = '{gh_id}' AND publish_timestamp > UNIX_TIMESTAMP('{run_date}');
         """
         response = self.long_articles_db_client.fetch(select_sql, cursor_type=DictCursor)
         UNLIMITED_PUSH = 3
@@ -489,7 +498,7 @@ class UpdatePublishedArticlesReadDetail(object):
             try:
                 self.process_single_account(account_info=account, run_date=biz_date)
                 success_count += 1
-                # time.sleep(5)
+                time.sleep(1)
             except Exception as e:
                 fail_count += 1
                 log(
@@ -530,7 +539,7 @@ class UpdatePublishedArticlesReadDetail(object):
         for account in tqdm(server_accounts):
             try:
                 self.process_single_account(account_info=account, run_date=biz_date)
-                time.sleep(5)
+                time.sleep(1)
             except Exception as e:
                 print(e)
         bot(