Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

没获取到bdstoken,请检查cookie和网络后重试. #35

Closed
ArloSmile opened this issue Jan 29, 2022 · 11 comments
Closed

没获取到bdstoken,请检查cookie和网络后重试. #35

ArloSmile opened this issue Jan 29, 2022 · 11 comments

Comments

@ArloSmile
Copy link

新注册的网盘出现这个问题,用老的网盘账号就一切正常。新注册的一直提示这个错误,是哪里问题

@hxz393
Copy link
Owner

hxz393 commented Jan 29, 2022

获取的cookie不正确,新号换新浏览器获取cookies

@HuntercodeT
Copy link

我用了很久的号了,抓了几十个Cookie,没有成功过,我看了一下某些请求的priview里面的result是有bdstoken的,但是该请求下的cookie一直提示无效,想问是不是百度网盘升级了导致无效?
我查看了过往的issues,发现bdstoken是用来创建文件夹的,那么如果我保存到已有文件夹下bdstoken还是必须的吗?如果非必须是否可以提供一个可选项,不勾选的话cookie不检测bdstoken,那样普通cookie也能将就用

@hxz393
Copy link
Owner

hxz393 commented Mar 1, 2022

确实不带bdstoken也可以转存文件,不过我更不明白的是失败的请求响应文本是什么?是没有获取到bdstoken还是获取到的bdstoken不能使用呢?可否发一份响应文本参考下呢?
获取响应文本步骤如下:
按F12打开Chrome浏览器的调试工具,访问地址https://pan.baidu.com/disk/home,并找到响应内容,类似如下开头:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>百度网盘-全部文件</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <meta http-equiv="Cache-Control" content="max-age=30"/>

我需要完整的文本来排查问题.

@HuntercodeT
Copy link

image

请求地址及状态码如上图

Response

<title>百度网盘</title><script>if (window.performance && window.performance.now) {
        window['__perf_white_screen'] = Math.round(window.performance.now && window.performance.now());
    }</script><script>window.locals = {"csrf":"N1JEMNFX-GgFfyR1IPdO0GxK9MgbI26kMRdg","isInCompany":false,"locked":false};</script><!--[if !IE]><!--><script src=https://staticiot.cdn.bcebos.com/union/badjs-sdk-min-1.3.0.js></script><script>window.BadJs && (window.BadSDK = new BadJs({
        host: 'https://pan.baidu.com',
        path: '/bpapi/analytics',
        namespace: 'netdisk_web_v20main',
        productId: '100720',
        rules: {path: true, hash: /(\/\w+)+/},
        clienttype: 0,
        promiseError: false,
        vueError: true,
        env: window,
        downgrade: {
            error: {p2: [/Script error/, /chrome-extension/]},
            resource: {p2: [/hm.baidu.com/, /webpush.pan.baidu.com/]}
        }
    }));</script><!--<![endif]--><style>#page {
        box-sizing: border-box;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 200;
        background: #fff;
        display: none;
        overflow: scroll;
    }

    #page {
        height: 100%;
    }

    a {
        text-decoration: none;
        cursor: pointer;
    }

    #main-content {
        max-width: 1068px;
        width: 1068px;
        position: absolute;
        top: 50%;
        left: 50%;
        margin: -178px 0 0 -534px;
    }

    #main-content.gt-four-browsers {
        margin-top: -254px;
    }

    #art {
        display: inline-block;
        float: left;
    }

    #browsers {
        display: inline-block;
        margin-left: 48px;
        max-width: 592px;
        width: 592px;
        float: left;
        margin-bottom: 16px;
    }

    h1 {
        font-family: PingFangSC-Regular, sans-serif, Microsoft YaHei, SimHei, Tahoma !important;
        font-weight: 500;
        margin-bottom: 16px;
        font-size: 32px;
        line-height: 48px;
    }

    #browsers p {
        margin-bottom: 24px;
        line-height: 21px;
    }

    .browser_not_supported-tip {
        margin-top: 100px;
        float: left;
    }

    .browsers-list {
        height: 141px;
        float: left;
        margin-bottom: 16px;
    }

    .browser {
        width: 136px;
        margin: 0 16px 16px 0;
        background: #f3f3f3;
        border-radius: 4px;
        float: left;
    }

    .browser a {
        display: block;
        width: 104px;
        margin: 16px 16px;
        color: #0d0d0d;
        box-sizing: content-box;
        text-align: center;
    }

    .browser a:visited {
        color: #0d0d0d;
    }

    .browser h3 {
        font-size: 14px;
        font-weight: 500;
        line-height: 16px;
        text-align: center;
    }

    @media (max-width: 1127px) {
        #main-content {
            max-width: 1030px;
        }

        #art {
            width: 390px;
            height: 260px;
        }
    }

    @media (max-width: 1069px) {
        #main-content {
            position: relative;
            top: inherit;
            left: inherit;
            margin: 0 auto;
            max-width: 640px;
            text-align: center;
        }

        #main-content.gt-four-browsers {
            margin-top: 0;
        }

        #browsers {
            margin-bottom: 24px;
            margin-left: 0;
        }

    }

    @media (max-width: 647px) {
        #main-content {
            margin: 16px auto;
            max-width: 440px;
        }

        #art {
            width: 360px;
            height: 240px;
        }

        .browsers-list {
            margin-right: -16px;
            text-align: left;
        }
    }

    @media (max-width: 491px) {
        #main-content {
            max-width: 288px;
        }

        h1 {
            font-size: 32px;
            line-height: 40px;
        }

        #art {
            width: 300px;
            height: 200px;
        }
    }

    #loading-container {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    @-webkit-keyframes rotator {
        0% {
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg)
        }

        100% {
            -webkit-transform: rotate(270deg);
            transform: rotate(270deg);
            -ms-transform: rotate(360deg)
        }
    }
    @keyframes rotator {
        0% {
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg)
        }

        100% {
            -webkit-transform: rotate(270deg);
            transform: rotate(270deg);
            -ms-transform: rotate(360deg)
        }
    }

    #loading-container .spinner {
        -webkit-animation: rotator 1.4s linear infinite;
        animation: rotator 1.4s linear infinite;
    }

    #loading-container .spinner .path {
        stroke-dasharray: 187;
        stroke-dashoffset: 50;
        -webkit-transform-origin: center;
        transform-origin: center;
        stroke: #4285F4;
        -webkit-animation: dash 1.4s ease-in-out infinite;
        animation: dash 1.4s ease-in-out infinite;
    }</style><!--[if lte IE 8]>
    <style>
        #page {
            display: block;
        }
    </style>
    <script type="text/javascript">
        var img = new Image();
        var commonSrc = '/api/analytics?clienttype=0&version=v20&type=web_v20_';
        img.src = commonSrc + 'no_support';
    </script>
<![endif]--><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-00a4006e.b2372a50.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-12111cb8.5702104e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-131eb720.562713db.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-19528ab2.439a71e5.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-1e54bba0.825d8981.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-2ace94b1.34f5d60a.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-3a496cbc.2606cae0.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-3f491e24.5702104e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-3f686fe4.73f586c0.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-481c79f4.aa7b5c4d.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-5033cfc2.5e8b3edf.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-6261c31c.1c269a81.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-63e607cf.f7f35ad6.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-65d08bf3.5702104e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-65fe1ba9.bf8fff07.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-661e82e6.9258e17b.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-6e38a484.d6045c54.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-793d9000.03aac5a3.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-79fe9a4c.a2ef8501.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-898de832.dbbb0cd2.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-93c639c6.5702104e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-b9f23352.5702104e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-c58a29f4.b6304fef.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-d12e5dea.745d0bb0.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-d9af00a8.5afa1ce7.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-df8f8292.c2b5fa91.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-eb46237e.1299df2e.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-f4fcd03a.bf0945a8.css rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-00a4006e.1ea0f7aa.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-12111cb8.9e39b07d.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-131eb720.40f40cb6.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-144b87ea.4c84a499.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-1783b158.ad43df6e.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-19528ab2.228ddad3.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-1e54bba0.182f8480.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2ace94b1.ecbca8f7.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d0a3c58.f4950e6e.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d0cfaf1.47dec275.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d0d2ae9.ac243d78.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d0e13a4.aa0a667a.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d0e9b9f.ba0e57cb.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-2d225474.5907aa3e.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-3a496cbc.1fab9207.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-3f491e24.657bee16.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-3f686fe4.75735dfd.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-481c79f4.592643f2.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-5033cfc2.3d2a8894.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-57545619.d47d916b.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-6261c31c.ad96dbd8.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-63e607cf.8421c864.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-65d08bf3.1c1b3132.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-65fe1ba9.15e963ed.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-661e82e6.01301c26.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-6e38a484.5dba7420.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-793d9000.e504d935.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-79fe9a4c.f0691068.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-898de832.57f7dde3.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-93c639c6.c291bf31.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-b9f23352.48ca7bcc.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-c58a29f4.7bfcb35c.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-d12e5dea.89fecf30.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-d9af00a8.49faab98.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-df8f8292.a1bab083.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-eb46237e.c14c5217.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-f4fcd03a.48e882d5.js rel=prefetch><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-vendors.32c94115.css rel=preload as=style><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/home.1c0ab552.css rel=preload as=style><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-vendors.874f4038.js rel=preload as=script><link href=https://nd-static.bdstatic.com/m-static/v20-main/js/home.5e728a48.js rel=preload as=script><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/chunk-vendors.32c94115.css rel=stylesheet><link href=https://nd-static.bdstatic.com/m-static/v20-main/css/home.1c0ab552.css rel=stylesheet></head><body><!--[if lte IE 8]>
<div id="page">
    <div id="main-content" class="gt-four-browsers">
        <img class="browser_not_supported-tip" id="art" width="420px" height="280px"
            src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/browser_not_supported.png">
        <div id="browsers">
            <h1>您正在使用的浏览器版本过低,将不能正常访问该页面!</h1>
            <p>您可以安装以下浏览器的最新版本来使用网盘的最新功能!</p>
            <div class="browsers-list">
                <div class="browser">
                    <a href="https://www.apple.com/safari/">
                        <img src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/safari.png" alt="" width="72px"
                            height="72px">
                        <h3>Safari</h3>
                    </a>
                </div>
                <div class="browser">
                    <a href="https://www.mozilla.org/firefox/new/">
                        <img src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/firefox.png" alt="" width="72px"
                            height="72px">
                        <h3>Mozilla Firefox</h3>
                    </a>
                </div>
                <div class="browser">
                    <a href="https://www.microsoft.com/edge">
                        <img src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/edgium.png" alt="" width="72px"
                            height="72px">
                        <h3>Microsoft Edge</h3>
                    </a>
                </div>
            </div>
            <div class="browsers-list">
                <div class="browser">
                    <a href="https://www.google.com/chrome/index.html">
                        <img src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/chrome.png" alt="" width="72px"
                            height="72px">
                        <h3>Google Chrome</h3>
                    </a>
                </div>
                <div class="browser last">
                    <a href="https://www.opera.com/">
                        <img src="https://ndstatic.cdn.bcebos.com/tongxunlu/images/opera.png" alt="" width="72px"
                            height="72px">
                        <h3>Opera</h3>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
<![endif]--><div id=app><div id=loading-container><svg class=spinner width=26px height=26px viewBox="0 0 66 66" xmlns=http://www.w3.org/2000/svg><circle class=path fill=none stroke-width=6 stroke-linecap=round cx=33 cy=33 r=30 style=stroke:#09aaff></circle></svg></div></div><script>if (window.location.href.match(/(protocol\/duty_mobi_tv)|(protocol\/vipduty_tv)|(protocol\/autoduty_tv)|(protocol\/privacy_policy_tv)/)) {
        document.body.style.background = 'transparent';
    }</script><script src=https://nd-static.bdstatic.com/m-static/v20-main/js/chunk-vendors.874f4038.js></script><script src=https://nd-static.bdstatic.com/m-static/v20-main/js/home.5e728a48.js></script></body></html>

@hxz393
Copy link
Owner

hxz393 commented Mar 3, 2022

我有注意到上面一句话

<h1>您正在使用的浏览器版本过低,将不能正常访问该页面!</h1>
<p>您可以安装以下浏览器的最新版本来使用网盘的最新功能!</p>

可能是因为浏览器的版本问题导致获取的cookie无效.
正确响应在返回名为require.resourceMap的json中带有bdstoken字段.

@junkfood214
Copy link

我有注意到上面一个句

<h1>您正在使用的浏览器版本过低,将不能正常访问该页面!</h1>
<p>您可以安装以下浏览器的最新版本来使用网盘的最新功能!</p>

可以是因为浏览蚀剂的版本问题导致获取的饼干无效。 正式响应在命名为要求.resourcemap的json中间没有bdstoken字段。

获取了bdstoken怎么正确添加到cookie中?按照bdstoken=*的格式添加进cookie中仍会提示没获取到bdstoken,请检查cookie和网络后重试

@hxz393
Copy link
Owner

hxz393 commented Mar 9, 2022

bdstoken是依据cookie自动获取的,如果想手动指定可以在代码255行将

bdstoken = get_bdstoken()

改成

bdstoken = '指定字符串'

我没测试过,不确定这样是否有效.

@junkfood214
Copy link

bdstoken是依据cookie自动获取的,如果想手动指定可以在代码255行将

bdstoken = get_bdstoken()

改成

bdstoken = '指定字符串'

我没测试过,不确定这样是否有效.
手动指定bdstoken后会出现
转存失败,错误代码(4)

@hxz393
Copy link
Owner

hxz393 commented Mar 9, 2022

说明问题出现在cookie,你也可以试试打开F12控制台,手动转存一个文件,查询到使用的cookie,再填入到软件中跑一下看.

@hanglife
Copy link

改了这两个地方可以用了

bdstoken = get_bdstoken()

这个指定的字符串是指bdstoken是看一个油猴脚本 妙传链接提取 获取的
将下面的data.result.bdstoken打印 替换

改成 bdstoken = '替换值'

        function getbdstoken() {
            ajax({
                url: bdstoken_url,
                method: "POST",
                responseType: "json",
                data: convertData({
                    fields: JSON.stringify([ "bdstoken" ])
                })
            }, (function(data) {
                data = data.response;
                if (!data.errno && data.result.bdstoken) setBdstoken(data.result.bdstoken); else showAlert("获取bdstoken失败(" + data.errno + "), 可能导致转存失败(#2), 请尝试刷新页面, 或重新登录");
            }), (function(statusCode) {
                showAlert("获取bdstoken失败(" + statusCode + "), 可能导致转存失败(#2), 请尝试刷新页面, 或重新登录");
            }));
        }

还有把下面两个模块注释
# 执行获取目录列表
# 执行新建目录

这样可以凑合用

@hxz393
Copy link
Owner

hxz393 commented Mar 14, 2022

已更新解决了bdstoken获取问题.

@hxz393 hxz393 closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants