fix:没有获取到所有版本时的处理

This commit is contained in:
jsz14 2023-09-02 19:58:24 +08:00
parent d052d425af
commit 03164bcb6f

View File

@ -57,9 +57,9 @@ def get_meta_information(url, chatbot, history):
except: except:
citation = 'cited by 0' citation = 'cited by 0'
abstract = result.select_one(".gs_rs").text.strip() # 摘要在 .gs_rs 中的文本,需要清除首尾空格 abstract = result.select_one(".gs_rs").text.strip() # 摘要在 .gs_rs 中的文本,需要清除首尾空格
other_versions = next((tag['href'] for tag in result.select_one('.gs_flb').select('.gs_nph') if 'cluster' in tag['href']), None) # 获取所有版本的链接
search = search_all_version('http://' + urlparse(url).netloc + other_versions)
try: try:
other_versions = next((tag['href'] for tag in result.select_one('.gs_flb').select('.gs_nph') if 'cluster' in tag['href']), None) # 获取所有版本的链接
search = search_all_version('http://' + urlparse(url).netloc + other_versions)
if search: if search:
paper = next(search.results()) paper = next(search.results())
abstract = paper.summary.replace('\n', ' ') abstract = paper.summary.replace('\n', ' ')