You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google Colab将Yandex Drive文件直接下载至Google Drive

解决Yandex Drive文件直接下载到Google Drive的问题

步骤1:正确挂载Google Drive

先确保Google Drive挂载正常,建议挂载到根目录后再指定保存子目录,示例代码:

from google.colab import drive
drive.mount('/content/drive')
# 创建目标保存目录(如果不存在)
!mkdir -p /content/drive/MyDrive/Yandex_Downloads

步骤2:获取Yandex Drive文件的直链

你用wget直接下载分享链接得到HTML页面,是因为Yandex的分享链接是网页入口,不是文件直链。可以用两种方式获取直链:

方法一:手动提取直链

  1. 打开你的Yandex分享链接https://disk.yandex.ru/d/KGA6qXDT87pTVA,进入文件页面
  2. 点击页面上的「下载」按钮,在弹出的下载窗口里,右键点击「保存文件」选项,选择「复制链接地址」,这个复制的就是文件直链

方法二:用脚本自动生成直链

如果手动提取麻烦,可以用Python脚本解析页面获取直链,先安装依赖:

!pip install beautifulsoup4

然后运行脚本:

import requests
from bs4 import BeautifulSoup

def get_yandex_direct_link(share_link):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
    }
    response = requests.get(share_link, headers=headers)
    soup = BeautifulSoup(response.text, 'html.parser')
    download_btn = soup.find('a', {'class': 'Button2 Button2_size_l Button2_view_action Button2_width_max'})
    if download_btn:
        direct_link = download_btn.get('href')
        if not direct_link.startswith('http'):
            direct_link = 'https://disk.yandex.ru' + direct_link
        return direct_link
    return None

# 生成你的文件直链
share_link = "https://disk.yandex.ru/d/KGA6qXDT87pTVA"
direct_link = get_yandex_direct_link(share_link)
print(direct_link)

步骤3:将文件下载到Google Drive

拿到直链后,用wget或curl下载到挂载的Google Drive目录:

# 替换为你的直链和自定义文件名
!wget -O /content/drive/MyDrive/Yandex_Downloads/target_file.zip "{direct_link}"

如果是大文件,推荐用aria2c加速下载,先安装:

!apt-get install aria2

再运行下载命令:

!aria2c -x 16 -s 16 "{direct_link}" -d /content/drive/MyDrive/Yandex_Downloads -o target_file.zip

-x和-s参数指定多线程数,能提升大文件的下载速度。

内容的提问来源于stack exchange,提问作者Nikita Artemenko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 12:37:10