feat: has_fulltext_pdf isf False时才去save

This commit is contained in:
caoqianming 2026-01-31 09:51:52 +08:00
parent e2687874eb
commit f7d14634f8
1 changed files with 8 additions and 4 deletions

View File

@ -21,6 +21,12 @@ config.retry_http_codes = [429, 500, 503]
OPENALEX_KEY = "NPimoE2ecdWmfdhH8abxEp" OPENALEX_KEY = "NPimoE2ecdWmfdhH8abxEp"
config.api_key = OPENALEX_KEY config.api_key = OPENALEX_KEY
ELSEVIER_APIKEY = 'aa8868cac9e27d6153ab0a0acd7b50bf'
ELSEVIER_HEAEDERS = {
"X-ELS-APIKey": ELSEVIER_APIKEY,
"X-ELS-Insttoken": "135fa874aea9f0de11cad187ccb4878c "
}
@shared_task(base=CustomTask) @shared_task(base=CustomTask)
def get_paper_meta_from_openalex(publication_year:int, keywords:str="", search:str="", end_year:int=None): def get_paper_meta_from_openalex(publication_year:int, keywords:str="", search:str="", end_year:int=None):
cache_key = f"openalex_cursor_{publication_year}_{keywords}{search}" cache_key = f"openalex_cursor_{publication_year}_{keywords}{search}"
@ -94,9 +100,6 @@ def get_paper_meta_from_openalex(publication_year:int, keywords:str="", search:s
countdown=5 countdown=5
) )
ELSEVIER_APIKEY = 'aa8868cac9e27d6153ab0a0acd7b50bf'
# 常用的 User-Agent 列表 # 常用的 User-Agent 列表
USER_AGENTS = [ USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
@ -191,7 +194,8 @@ def get_abstract_from_elsevier(number_of_task:int = 20):
if has_fulltext: if has_fulltext:
paper.has_fulltext = True paper.has_fulltext = True
paper.has_fulltext_xml = True paper.has_fulltext_xml = True
save_pdf_from_elsevier(paper) if paper.has_fulltext_pdf is False:
save_pdf_from_elsevier(paper)
count_fulltext += 1 count_fulltext += 1
paper.save_file_xml(xml_str) paper.save_file_xml(xml_str)