diff --git a/spiders/ai_seo/tongyi.py b/spiders/ai_seo/tongyi.py index fcd4774..a9a6f1e 100644 --- a/spiders/ai_seo/tongyi.py +++ b/spiders/ai_seo/tongyi.py @@ -91,6 +91,7 @@ class TongyiSpider(AbstractAiSeoSpider): stream = await response.body() response_text = stream.decode('utf-8') datas = response_text.split("\n") + # print("datas:",datas) # 合规数据转成字典 for data_str in datas: if not data_str or data_str == 'data: [DONE]': @@ -111,9 +112,9 @@ class TongyiSpider(AbstractAiSeoSpider): if content_type == 'plugin': logger.debug(f"获取到联网搜索结果") if self.think: - search_result_list = glom(content, 'content.pluginResult', default=[]) + search_result_list = glom(content, 'content.pluginResult.links', default=[]) else: - search_result_list = glom(content, 'content.pluginResult.-1.search_results', default=[]) + search_result_list = glom(content, 'content.pluginResult.links.-1.search_results', default=[]) # for search_result in search_result_list: # url = search_result.get('url', '') # title = search_result.get('title', '') @@ -124,9 +125,9 @@ class TongyiSpider(AbstractAiSeoSpider): # ai_search_result_list.append( # AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time) # ) - if content_type == 'text': + if content_type == 'think': logger.debug(f'获取到ai回复结果') - answer = content.get('content', '') + answer = content.get('content', '').get('content', '') logger.debug(f"ai回复: {answer}") self.ai_answer.answer = answer pattern = r'ty-reference]\((\d+)\)' @@ -143,7 +144,7 @@ class TongyiSpider(AbstractAiSeoSpider): is_referenced = "0" logger.debug(f"ai参考资料: [{host_name}]{title}({url})") ai_search_result_list.append( - AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time,is_referenced=is_referenced) + AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time , is_referenced=is_referenced) ) if ai_search_result_list: self.ai_answer.search_result = ai_search_result_list