自动上传数据到百度云

自动上传到百度云shell脚本

步骤 1 登录网页版百度云

baiduyun

步骤 2



#!/bin/sh

baiduyun()
{
    from="$1"
    to="$2"

    [ -d "${from}" ]&& {
        tar -cvzf ${from}.tar.gz "${from}"
        from="${from}.tar.gz"
    }

    [ "${to}" == "" ] && to="/upload/`date +%F`"
    echo "upload ${from} to baiduyun : ${to}"
    fileName=${from##*/}
    encodeFile=$(python -c "import urllib; print urllib.quote('''$fileName''')")
    dir=$(python -c "import urllib; print urllib.quote('''${to}''')")

   httpcode=$(curl --connect-timeout 15 -m 3600 -k -o /dev/null -s -w %{http_code} \
    -X POST \
    -F file="@${from}" \
    -F filename="${fileName}" \
    -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
    -H 'Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3' \
    -H 'Cache-Control: no-cache' \
    -H 'Connection: keep-alive' \
    -H 'DNT: 1' \
    -H 'Host: c.pcs.baidu.com' \
    -H 'Origin: http://pan.baidu.com' \
    -H 'Pragma: no-cache' \
    -H 'Referer: http://pan.baidu.com/disk/home' \
    -H 'Accept-Encoding: identity' \
    -H 'User-Agent: Mozilla/5.0 (X11; Linux; rv:5.0) Gecko/5.0 Firefox/5.0' \
    -H 'Cookie: BDUSS=你的cookie' \
    "https://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&ondup=overwrite&app_id=250528&dir=${dir}&filename=${encodeFile}")

    echo ${httpcode}
}

baiduyun "$@"


图片描述

更多有趣高效的脚本和文章========> www.rocyuan.com

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值