소스 검색

feat:添加爬取计划筛选条件清空的逻辑

zhaohaipeng 3 주 전
부모
커밋
d84a9bf651
2개의 변경된 파일67개의 추가작업 그리고 1개의 파일을 삭제
  1. 30 1
      client/AIGCClient.py
  2. 37 0
      script/aigc_crawler_plan_clear_filters.py

+ 30 - 1
client/AIGCClient.py

@@ -1,4 +1,5 @@
 import json
+from typing import Tuple
 
 import requests
 
@@ -16,7 +17,35 @@ class AIGCClient(object):
         url = f"{self.base_url}/aigc/produce/plan/updatePlanStatus"
         self.post(url, params)
 
-    def post(self, url: str, params: dict):
+    def get_content_crawler_plan_by_id(self, crawler_plan_id: str) -> Tuple[str, dict]:
+        params = {
+            "filterItems": [
+                {
+                    "itemName": "id",
+                    "selectValues": [
+                        crawler_plan_id
+                    ]
+                }
+            ],
+            "pageNum": 1,
+            "pageSize": 100,
+            "contentModal": 4
+        }
+        resp = self.get_content_crawler_plan_list(params=params)
+        if resp['code'] == 0 and resp['data']['data']:
+            return "", resp['data']['data'][0]
+        else:
+            return resp['msg'], {}
+
+    def get_content_crawler_plan_list(self, params: dict) -> dict:
+        url = f"{self.base_url}/aigc/crawler/plan/list/contentCrawlerPlan"
+        return self.post(url, params)
+
+    def crawler_plan_save(self, params: dict):
+        url = f"{self.base_url}/aigc/crawler/plan/save"
+        return self.post(url, params)
+
+    def post(self, url: str, params: dict) -> dict:
         request_param = {
             "params": params,
             "baseInfo": {

+ 37 - 0
script/aigc_crawler_plan_clear_filters.py

@@ -0,0 +1,37 @@
+from client.AIGCClient import AIGCClient
+
+aigc_client = AIGCClient(token="8bf14f27fc3a486788f3383452422d72", base_url="https://aigc-api.aiddit.com")
+
+
+def _main():
+    crawler_plan_ids = [
+        "20260112220200878311844",
+        "20260112220402220841959",
+        "20260112220502939933244",
+        "20260112220531828165492",
+        "20260112220643629142255",
+        "20260112220821537298585",
+        "20260112220847790433437",
+        "20260113010110579630364",
+        "20260113010139069870987",
+        "20260113010249165202977",
+        "20260112220038987749267",
+        "20260112220333196236758",
+        "20260112220607572749425",
+        "20260112220715218387191",
+        "20260112220752706640482",
+        "20260113010023885861741",
+        "20260113010053572102316"
+    ]
+
+    for crawler_plan_id in crawler_plan_ids:
+        msg, crawler_plan_info = aigc_client.get_content_crawler_plan_by_id(crawler_plan_id)
+        update_data = crawler_plan_info["updateData"]
+        update_data['accountFilters'] = []
+        update_data['contentFilters'] = []
+        update_data['frequencyType'] = 2
+        print(aigc_client.crawler_plan_save(update_data))
+
+
+if __name__ == '__main__':
+    _main()