Linux下载OneDrive分享文件
Posted herosunly
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下载OneDrive分享文件相关的知识,希望对你有一定的参考价值。
大家好,我是 herosunly。985 院校硕士毕业,现担任算法研究员一职,热衷于机器学习算法研究与应用。曾获得阿里云天池安全恶意程序检测第一名,科大讯飞恶意软件分类挑战赛第三名,CCF 恶意软件家族分类第四名,科大讯飞阿尔茨海默综合症预测挑战赛第四名,科大讯飞事件抽取挑战赛第七名,Datacon 大数据安全分析比赛第五名。拥有多项发明专利。对机器学习和深度学习拥有自己独到的见解。今天给大家分享的是Linux下载OneDrive分享文件,欢迎大家在评论区留言,和大家一起成长进步。
朋友使用OneDrive分享数据文件,但由于个人的Windows环境下载网速比较慢,所以使用Linux系统下载数据文件。
需要解决方案的朋友阅读第一部分即可,第二部分仅仅是对踩坑方案进行汇总,避免后续在相同的地方踩坑。
文章目录
1. 解决方案
1.1 使用FireFox获得下载链接
打开FireFox,按F12打开开发人员工具,然后转到网络选项。点击左上角的下载或者点击文件进行下载,同时观察开发人员工具窗口,找到带有download.aspx/?…. 的链接,如下图所示:
在上图中红框的位置点击鼠标右键,然后点击复制,点击复制为cURL命令(POSIX),如下图所示:
1.2 下载文件
在上述复制的内容后添加–output filename,并输入shell窗口则开始下载,比如:
curl https://pkueducn-my.sharepoint.com/personal/pkucp_pku_edu_cn/_layouts/15/download.aspx?SourceUrl=%2Fpersonal%2Fpkucp%5Fpku%5Fedu%5Fcn%2FDocuments%2Ffiles%2Fproject%26dataset%2FISCXTOR2016%2FTorCSV%2Ezip -H User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0 -H Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 -H Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 -H Accept-Encoding: gzip, deflate, br -H Referer: https://pkueducn-my.sharepoint.com/personal/pkucp_pku_edu_cn/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fpkucp%5Fpku%5Fedu%5Fcn%2FDocuments%2Ffiles%2Fproject%26dataset%2FISCXTOR2016%2FTorCSV%2Ezip&parent=%2Fpersonal%2Fpkucp%5Fpku%5Fedu%5Fcn%2FDocuments%2Ffiles%2Fproject%26dataset%2FISCXTOR2016 -H Upgrade-Insecure-Requests: 1 -H Sec-Fetch-Dest: iframe -H Sec-Fetch-Mode: navigate -H Sec-Fetch-Site: same-origin -H Connection: keep-alive -H Cookie: RpsContextCookie=U291cmNlPSUyRnBlcnNvbmFsJTJGcGt1Y3AlNUZwa3UlNUZlZHUlNUZjbiUyRiU1RmxheW91dHMlMkYxNSUyRm9uZWRyaXZlJTJFYXNweCUzRmlkJTNEJTI1MkZwZXJzb25hbCUyNTJGcGt1Y3AlNUZwa3UlNUZlZHUlNUZjbiUyNTJGRG9jdW1lbnRzJTI1MkZmaWxlcyUyNTJGcHJvamVjdCUyNTI2ZGF0YXNldCUyNTJGSVNDWFRPUjIwMTYlMjUyRlRvclBjYXBzJTJFemlwJTI2cGFyZW50JTNEJTI1MkZwZXJzb25hbCUyNTJGcGt1Y3AlNUZwa3UlNUZlZHUlNUZjbiUyNTJGRG9jdW1lbnRzJTI1MkZmaWxlcyUyNTJGcHJvamVjdCUyNTI2ZGF0YXNldCUyNTJGSVNDWFRPUjIwMTYmUHJldmlvdXNSZXF1ZXN0Q29ycmVsYXRpb25JZD0zOTc3MjNhMCUyRGIwMTAlMkQzMDAwJTJEYzcyOCUyRDNjNDk5ZjI3NmNkMiZSZXR1cm5Vcmw9JTJGcGVyc29uYWwlMkZwa3VjcCU1RnBrdSU1RmVkdSU1RmNuJTJGJTVGbGF5b3V0cyUyRjE1JTJGQXV0aGVudGljYXRlJTJFYXNweCUzRlNvdXJjZSUzRCUyNTJGcGVyc29uYWwlMjUyRnBrdWNwJTI1NUZwa3UlMjU1RmVkdSUyNTVGY24lMjUyR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I4TksyRWxMK2RaL1hUZHhwdUM5YllBcngxTnNYcFFUVG94bEE9PTwvU1A+; KillSwitchOverrides_enableKillSwitches=; KillSwitchOverrides_disableKillSwitches= --output data.csv
2. 各种错误方法总结
2.1 403 Forbidden
如果在上图中使用FireFox复制的不是cURL命令而选择的是复制网址,则会出现403 Forbidden:
wget https://pkueducn-my.sharepoint.com/personal/pkucp_pku_edu_cn/_layouts/15/download.aspx?SourceUrl=%2Fpersonal%2Fpkucp%5Fpku%5Fedu%5Fcn%2FDocuments%2Ffiles%2Fproject%26dataset%2FISCXTOR2016%2FTorCSV%2Ezip
分析原因后是由于没有Cookie信息导致的上述错误。
2.2 下载完为HTML文件
在原始链接的基础上添加了download=1以及后续的-o选项,但是下载后得到的是HTML文件,例如:
wget https://pkueducn-my.sharepoint.com/:u:/g/personal/pkucp_pku_edu_cn/ETTxDepoRRBEq-IhUBn3gl4Bf55PRdgrWrcUL4fOrb-gmw?e=a5NXKP&download=1 -o pcap.zip
当然,也尝试了不加download=1的下载方法,结果也是HTML文件。
2.3 使用迅雷下载
使用迅雷下载得到的链接,修改文件名后依然得到的是HTML文件。
以上是关于Linux下载OneDrive分享文件的主要内容,如果未能解决你的问题,请参考以下文章
UWP 使用Windows Community Toolkit 的OneDrive service上传下载文件
使用Aria2+Aria2Ng+OneIndex+OneDrive建立不限流量/离线BT下载/在线观看网盘/在线存储分享平台