Browse Source

取消调用情感分析接口

master
zhurunlin 4 months ago
parent
commit
12b3d9d955
  1. 4
      domain/ai_seo.py
  2. 60
      run.py

4
domain/ai_seo.py

@ -25,10 +25,10 @@ class AiSearchResult:
#是否被ai引用 #是否被ai引用
is_referenced: str = '0' is_referenced: str = '0'
#情感倾向" 1- 中立 2- 正面 3- 负面 #情感倾向" 1- 中立 2- 正面 3- 负面
sentiment_type = ""
sentiment_type = 0
#情感类型 #情感类型
type = ''
type = 0
def __post_init__(self): def __post_init__(self):
if isinstance(self.publish_time, float): if isinstance(self.publish_time, float):
self.publish_time = int(self.publish_time) self.publish_time = int(self.publish_time)

60
run.py

@ -81,7 +81,31 @@ async def ai_seo_job(browser, platform_ids, time_range, job_id, type_name, run_i
platform_str = ','.join(platform_ids) platform_str = ','.join(platform_ids)
# 获取任务信息 # 获取任务信息
task_data = await AiSeoApis.get_one_task(date=date, platform_ids=platform_str) task_data = await AiSeoApis.get_one_task(date=date, platform_ids=platform_str)
# task_data = {
# "id": "778877538494716115",
# "project_id": "778865951931242406",
# "keyword_id": "778865954200359933",
# "keyword": "考研班哪个机构好",
# "brand": "高顿教育",
# "platform_id": "13",
# "gather_date": "2025-06-26",
# "gather_time": "00:00",
# "gather_filter": "2025-06-26 00:00:00",
# "status": 2,
# "retry_count": 0,
# "screen_flag": 2,
# "thinking": 1,
# "is_deal": 1,
# "screen_url": "",
# "priority": 999,
# "start_time": "null",
# "end_time": "null",
# "create_time": "2025-06-26 15:09:24",
# "update_time": "2025-06-26 18:19:55",
# "delete_time": 0,
# "create_by": "777786292267261539",
# "update_by": "777786292267261539"
# }
if not task_data: if not task_data:
logger.info(f'[{type_name}]未获取到任务信息') logger.info(f'[{type_name}]未获取到任务信息')
# current_job.resume() # current_job.resume()
@ -144,23 +168,23 @@ async def ai_seo_job(browser, platform_ids, time_range, job_id, type_name, run_i
answer_data['rank'] = rank answer_data['rank'] = rank
answer_data['words'] = brands answer_data['words'] = brands
# print('answer_data',answer_data) # print('answer_data',answer_data)
search_results = list()
for data in answer_data.get("search_result"):
data_ = {**config.AI_SEO_API_AUTH,"content": data.get("title")}
rest = ''
try:
resp = requests.post(url='https://geo-api.neicela.com/api/third/getSentimentType',json=data_,timeout=600)
# print(resp.text)
rest = resp.json()
except Exception as e:
print(str(e))
# logger.info("调用getSentimentType接口出现异常:",str(e))
# print("rest",rest)
if rest.get("code") == 0:
data.update(rest.get("data"))
search_results.append(data)
answer_data['search_result'] = search_results
# search_results = list()
# for data in answer_data.get("search_result"):
# data_ = {**config.AI_SEO_API_AUTH,"content": data.get("title")}
# rest = ''
# try:
# resp = requests.post(url='https://geo-api.neicela.com/api/third/getSentimentType',json=data_,timeout=600)
# # print(resp.text)
# rest = resp.json()
# except Exception as e:
# print(str(e))
# # logger.info("调用getSentimentType接口出现异常:",str(e))
#
# print("rest",rest)
# if rest.get("code") == 0:
# data.update(rest.get("data"))
# search_results.append(data)
# answer_data['search_result'] = search_results
result = await AiSeoApis.submit_task(answer_data) result = await AiSeoApis.submit_task(answer_data)
logger.info(f"任务提交成功: id: {task_data['id']}") logger.info(f"任务提交成功: id: {task_data['id']}")
spider_pool.pop(run_id, None) spider_pool.pop(run_id, None)

Loading…
Cancel
Save