Skip to content

Commit

Permalink
Merge pull request #748 from duhaode520/master
Browse files Browse the repository at this point in the history
🐞 fix(谷歌学术搜索): 包装search.results()为空可能造成的报错
  • Loading branch information
binary-husky committed May 15, 2023
2 parents f2a55dc + 3f31fb9 commit 5f79fed
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crazy_functions/谷歌检索小助手.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ def string_similar(s1, s2):
max_results = 1,
sort_by = arxiv.SortCriterion.Relevance,
)
paper = next(search.results())
if string_similar(title, paper.title) > 0.90: # same paper
abstract = paper.summary.replace('\n', ' ')
is_paper_in_arxiv = True
else: # different paper
try:
paper = next(search.results())
if string_similar(title, paper.title) > 0.90: # same paper
abstract = paper.summary.replace('\n', ' ')
is_paper_in_arxiv = True
else: # different paper
abstract = abstract
is_paper_in_arxiv = False
paper = next(search.results())
except:
abstract = abstract
is_paper_in_arxiv = False
paper = next(search.results())
print(title)
print(author)
print(citation)
Expand Down

0 comments on commit 5f79fed

Please sign in to comment.