binary-husky/gpt_academic · error · Exception
无法下载论文 {self.doi},所有重试都失败了
Error message
无法下载论文 {self.doi},所有重试都失败了 What it means
Top-level retry exhaustion in the SciHub downloader: the download is attempted 3 times (with 3s/6s backoff between), and if every attempt raises, it fails with Exception('无法下载论文 {doi},所有重试都失败了'). The per-attempt errors are only in logs; the raised message does not include the last cause.
Source
Thrown at crazy_functions/review_fns/data_sources/scihub_source.py:296
continue
# 保存PDF文件
pdf_name = f"{self.doi.replace('/', '_').replace(':', '_')}.pdf"
pdf_path = self.path.joinpath(pdf_name)
pdf_path.write_bytes(pdf_content)
logger.info(f"成功下载论文: {pdf_name},文件大小: {len(pdf_content)} bytes")
return str(pdf_path)
except Exception as e:
logger.error(f"第 {attempt + 1} 次尝试失败: {str(e)}")
if attempt < 2: # 不是最后一次尝试
wait_time = (attempt + 1) * 3 # 递增等待时间
logger.info(f"等待 {wait_time} 秒后重试...")
time.sleep(wait_time)
continue
raise Exception(f"无法下载论文 {self.doi},所有重试都失败了")
# Usage Example
if __name__ == '__main__':
# 创建一个用于保存PDF的目录
save_path = Path('./downloaded_papers')
save_path.mkdir(exist_ok=True)
# DOI示例
sample_doi = '10.3897/rio.7.e67379' # 这是一篇Nature的论文DOI
try:
# 初始化SciHub下载器,先尝试使用代理
logger.info("尝试使用代理模式...")
downloader = SciHub(doi=sample_doi, path=save_path, use_proxy=True)
# 开始下载
result = downloader.fetch()
print(f"论文已保存到: {result}")View on GitHub (pinned to d6bde0fa54)
Solutions
- Read the preceding log lines ('第 N 次尝试失败: ...') to identify which stage fails — mirror, extraction, or PDF fetch.
- Test the DOI manually in a browser on a live mirror to confirm SciHub actually has the paper.
- Fix the environment: working proxy, updated mirror list, longer timeout.
- If the paper is on arXiv, use ArxivSource.download_pdf instead of SciHub.
Defensive patterns
Strategy: fallback
Try / catch
try:
pdf = scihub.download(doi, dirpath)
except Exception as e:
if '所有重试都失败了' in str(e):
logger.warning('SciHub failed for %s, trying open-access sources', doi)
pdf = try_open_access(doi) # arXiv / unpaywall / publisher OA
if pdf is None:
raise
else:
raise Prevention
- Treat SciHub as best-effort: chain it after legal/open-access sources with a fallback chain.
- Check the per-attempt log lines — they carry the root cause the final message omits.
- Confirm network/proxy health before retry loops; blind retries against a blocked network waste minutes.
When it happens
Trigger: All three attempts hit the failure chain: mirror discovery fails (error 87), all mirrors fail the POST (error 88), PDF link extraction from the returned HTML fails (no #pdf element/iframe), or downloading the extracted PDF content fails — then this exception surfaces from the download-by-DOI entry point.
Common situations: Blocked/unstable network to SciHub over the whole retry window; DOI not in SciHub's holdings so every page lacks a PDF element; captcha interstitials on every attempt; proxy timeouts under 30s while SciHub is slow.
Related errors
- 所有可用镜像站点均无法完成下载
- 无法下载资源{txt},请检查。
- Failed to download webpage after {self.config.max_retries} a
- Doc2x return an error: {res.json()}
- 没有找到可用的镜像站点
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/b5032667703b9bc4.
Report an issue: GitHub.