Просмотр исходного кода

广告互选平台-账号抓取

luojunhui 1 день назад
Родитель
Сommit
d8562d24a4

+ 0 - 4
app/domains/monitor_tasks/ad_platform_accounts_monitor/_mapper.py

@@ -86,10 +86,6 @@ class AdPlatformAccountsMonitorMapper(AdPlatformAccountsMonitorTaskConst):
             UPDATE ad_platform_accounts_daily_detail SET
                 article_text = %s,
                 article_images = %s,
-                read_cnt = %s,
-                like_cnt = %s,
-                share_cnt = %s,
-                looking_cnt = %s,
                 publish_timestamp = %s,
                 fetch_status = %s
             WHERE wx_sn = %s AND fetch_status = %s;

+ 9 - 9
app/domains/monitor_tasks/ad_platform_accounts_monitor/entrance.py

@@ -32,12 +32,11 @@ class AdPlatformAccountsMonitorTask(AdPlatformAccountsMonitorTaskConst):
             print("锁抢占失败")
             return acquire_lock
 
-        article_detail = await get_article_detail(
-            article_link, is_count=True, is_cache=False
-        )
+        article_detail = await get_article_detail(article_link)
         if not article_detail:
+            # 如果爬虫偶发失败,则回退为 init 状态
             return await self.mapper.update_fetch_status(
-                wx_sn, self.PROCESSING_STATUS, self.FAIL_STATUS
+                wx_sn, self.PROCESSING_STATUS, self.INIT_STATUS
             )
 
         # 更新文章信息
@@ -51,10 +50,10 @@ class AdPlatformAccountsMonitorTask(AdPlatformAccountsMonitorTaskConst):
                     params = (
                         article.get("body_text", None),
                         self.tool.json_dumps(images),
-                        article.get("view_count", None),
-                        article.get("like_count", None),
-                        article.get("share_count", None),
-                        article.get("looking_count", None),
+                        # article.get("view_count", None),
+                        # article.get("like_count", None),
+                        # article.get("share_count", None),
+                        # article.get("looking_count", None),
                         int(article.get("publish_timestamp", 0) / 1000),
                         self.SUCCESS_STATUS,
                         wx_sn,
@@ -241,8 +240,9 @@ class AdPlatformAccountsMonitorTask(AdPlatformAccountsMonitorTaskConst):
                 article_list = await self.mapper.get_head_article_list()
                 for article in tqdm(article_list, desc="处理文章详情"):
                     try:
-                        print(article)
                         await self.set_article_detail(article)
+                        # 等待一会儿
+                        await self.tool.sleep_between_each_request()
 
                     except Exception as e:
                         print(f"获取文章详情失败-{article['article_link']}-{e}")