Merge pull request #748 from duhaode520/master

🐞 fix(谷歌学术搜索): 包装search.results()为空可能造成的报错
This commit is contained in:
binary-husky 2023-05-15 17:27:41 +08:00 committed by GitHub
commit 5f79fed566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,7 @@ def get_meta_information(url, chatbot, history):
max_results = 1, max_results = 1,
sort_by = arxiv.SortCriterion.Relevance, sort_by = arxiv.SortCriterion.Relevance,
) )
try:
paper = next(search.results()) paper = next(search.results())
if string_similar(title, paper.title) > 0.90: # same paper if string_similar(title, paper.title) > 0.90: # same paper
abstract = paper.summary.replace('\n', ' ') abstract = paper.summary.replace('\n', ' ')
@ -44,6 +45,9 @@ def get_meta_information(url, chatbot, history):
abstract = abstract abstract = abstract
is_paper_in_arxiv = False is_paper_in_arxiv = False
paper = next(search.results()) paper = next(search.results())
except:
abstract = abstract
is_paper_in_arxiv = False
print(title) print(title)
print(author) print(author)
print(citation) print(citation)