binary-husky/gpt_academic · error · Exception

没有找到可用的镜像站点

Error message

没有找到可用的镜像站点

What it means

SciHubSource probes its list of mirror URLs with a quick GET (10s timeout) and keeps those returning HTTP 200; if none pass, it raises Exception('没有找到可用的镜像站点'). This is an environment/network outcome — every known SciHub mirror is unreachable, blocked, or answering non-200 from the current host.

Source

Thrown at crazy_functions/review_fns/data_sources/scihub_source.py:116

        for mirror in self.MIRRORS:
            try:
                test_response = requests.get(
                    mirror,
                    headers=self.headers,
                    proxies=self.proxies,
                    timeout=10
                )
                if test_response.status_code == 200:
                    working_mirrors.append(mirror)
                    logger.info(f"镜像 {mirror} 可用")
                    if len(working_mirrors) >= 5:  # 找到5个可用镜像就够了
                        break
            except Exception as e:
                logger.debug(f"镜像 {mirror} 不可用: {str(e)}")
                continue

        if not working_mirrors:
            raise Exception("没有找到可用的镜像站点")

        logger.info(f"找到 {len(working_mirrors)} 个可用镜像,开始尝试下载...")

        # 使用可用的镜像进行下载
        for mirror in working_mirrors:
            try:
                res = requests.post(
                    mirror,
                    headers=self.headers,
                    data=self.payload,
                    proxies=self.proxies,
                    timeout=self.timeout
                )
                if res.ok:
                    logger.info(f"成功使用镜像站点: {mirror}")
                    self.url = mirror  # 更新当前使用的镜像
                    time.sleep(1)  # 降低等待时间以提高效率
                    return res

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Check basic connectivity: curl -I https://sci-hub.se (and the other mirrors) from the same host; if all are blocked, configure self.proxies with a working proxy.
  2. Update the mirror list in scihub_source.py to currently-live domains (they change often).
  3. If a proxy is already configured, verify it actually works for these domains — a broken proxy makes every probe fail.
  4. As a fallback, obtain the paper through the arXiv/publisher source instead of SciHub.
Defensive patterns

Strategy: fallback

Validate before calling

import requests

def any_mirror_reachable(mirrors, timeout=10, proxies=None) -> bool:
    return any(
        requests.get(m, timeout=timeout, proxies=proxies).status_code == 200
        for m in mirrors
    )

Try / catch

try:
    pdf = scihub.download(doi)
except Exception as e:
    if '没有找到可用的镜像站点' in str(e):
        logger.warning('SciHub unreachable from this network; falling back to arXiv')
        pdf = await arxiv_source.download_pdf(paper_id, dirpath)  # fallback path
    else:
        raise

Prevention

When it happens

Trigger: Calling the SciHub download path when every mirror in the built-in list times out (10s), resolves to a dead domain, returns 403/captcha pages, or when the host has no internet egress to those domains. Proxies configured via self.proxies can also route probes into a block page.

Common situations: ISP/country-level blocking of scihub domains; mirrors rotating frequently so the hardcoded list is stale; corporate proxy or DNS filtering; running in CI/cloud sandboxes with restricted egress.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/c0212485bd8cb56e. Report an issue: GitHub.