luojunhui 2 miesięcy temu
rodzic
commit
e0b6a1aa86
2 zmienionych plików z 18 dodań i 7 usunięć
  1. 4 5
      account_cold_start_daily.py
  2. 14 2
      coldStartTasks/filter/__init__.py

+ 4 - 5
account_cold_start_daily.py

@@ -8,7 +8,7 @@ from applications import longArticlesMySQL, bot
 from coldStartTasks.crawler.weixinCategoryCrawler import weixinCategory
 from coldStartTasks.publish.publishCategoryArticles import CategoryColdStartTask
 
-DEFAULT_CATEGORY_LIST = ['1030-手动挑号']
+DEFAULT_CATEGORY_LIST = ['1030-手动挑号', 'account_association']
 
 
 class AccountColdStartDailyTask(object):
@@ -113,10 +113,9 @@ def main(category_list=None, article_source=None):
 
 
 if __name__ == '__main__':
-    main()
-    # # 执行微信抓取发布
-    # main()
-    #
+    # 执行微信抓取发布
+    main(['1030-手动挑号'])
+
     # # 执行头条发布
     # main(
     #     category_list=['history', 'tech', 'finance', 'entertainment'],

+ 14 - 2
coldStartTasks/filter/__init__.py

@@ -12,7 +12,13 @@ def article_crawler_duplicate_filter(new_article_title, db_client) -> bool:
     select_sql = f"""
         select article_id from crawler_meta_article where title = '{new_article_title}';
     """
-    response = db_client.select(select_sql)
+    if hasattr(db_client, "fetch"):
+        response = db_client.fetch(select_sql)
+    elif hasattr(db_client, "select"):
+        response = db_client.select(select_sql)
+    else:
+        raise AttributeError("db_client must has fetch or select method")
+
     if response:
         return True
     else:
@@ -28,7 +34,13 @@ def video_crawler_duplicate_filter(new_video_title, db_client) -> bool:
     select_sql = f"""
         select article_title from publish_single_video_source where article_title = '{new_video_title}';
     """
-    response = db_client.select(select_sql)
+    if hasattr(db_client, "fetch"):
+        response = db_client.fetch(select_sql)
+    elif hasattr(db_client, "select"):
+        response = db_client.select(select_sql)
+    else:
+        raise AttributeError("db_client must has fetch or select method")
+
     if response:
         return True
     else: