Delphi百度网盘真实地址解析


本文整理自网络,侵删。

 写在前边
这里用Delphi演示下获取百度网盘的真实地址,里面一些参数拼接是根据浏览器抓包来的。这里给出了部分源码。
url网址使用于百度分享的地址。暂时没有适配有提取码的地址。
目前,获取
查看更多关于 获取 的文章
到百度网盘真实地址也会限速了,亲测用IDM下载工具最高到600+kb/s
测试环境
Delphi 10.2.3 Tokyo

Windows 7

api地址

var

  panUrlRe: string;

begin

  try

    try

        panUrlRe := FIDHttp.Get(panUrl);

        sign := GetMidString(panUrlRe, 'sign":"', '",');

        timestamp := GetMidString(panUrlRe, 'timestamp":', ',');

        app_id := GetMidString(panUrlRe, 'app_id":"', '",');

        bdstoken := GetMidString(panUrlRe, 'bdstoken":', ',');

        fid_list := GetMidString(panUrlRe, '"fs_id":', ',');

        primaryid := GetMidString(panUrlRe, 'shareid":', ',');

        uk := GetMidString(panUrlRe, 'uk=', '&');

        apiurl := 'https://pan.baidu.com/api/sharedownload?sign=' + sign +

          '&timestamp=' + timestamp + '&channel=chunlei&web=1' + '&app_id=' +

          app_id + '&bdstoken=' + bdstoken;

        wa := '1';

      end;

    except

      on e: exception do

        TThread.Synchronize(TThread.CurrentThread,

          procedure

          begin

            MainForm.Memo1.Lines.Add(e.Message);

          end);

    end;

 

  finally

    TThread.Synchronize(TThread.CurrentThread,

      procedure

      begin

        MainForm.ActivityIndicator1.Animate := False;

      end);

  end;

获取真实地址

var

  VcodUrl: string;

begin

  try

    try

      postinstr := TstringList.Create;

      postinstr.Add('encrypt=' + '0');

      postinstr.Add('fid_list=[' + fid_list + ']');

      postinstr.Add('path_list=');

      postinstr.Add('primaryid=' + primaryid);

      postinstr.Add('product=' + 'share');

      postinstr.Add('uk=' + uk);

      postResult := Fidhttp.Post(apiurl, postinstr);

      realUrl := StringReplace(GetMidString(postResult, 'dlink":"', '",'), '\',

        '', [rfReplaceAll]);

      if pos('-20', postResult) > 0 then

      begin

        VcodUrl :=

          'https://pan.baidu.com/api/getvcode?prod=pan&channel=chunlei&web=1&app_id='

          + app_id + '&bdstoken=' + bdstoken;

        vcodeRe := Fidhttp.Get(VcodUrl);

        vcode_str := GetMidString(vcodeRe, 'vcode":"', '",');

        imageUrl := StringReplace(GetMidString(vcodeRe, 'img":"', '"}'), '\',

          '', [rfReplaceAll]);

        TThread.Synchronize(TThread.CurrentThread,

          procedure

          begin

            MainForm.ActivityIndicator1.Animate := False;

            vcodeForm.ShowModal;

          end);

      end

      else

      begin

        TThread.Synchronize(TThread.CurrentThread,

          procedure

          begin

            MainForm.Memo1.Lines.Add('百度真实地址为(8小时有效):' + realUrl);

            MainForm.Edit2.Text := realUrl;

          end);

        IdSSLIOHandlerSocketOpenSSL1.DisposeOf;

        Fidhttp.DisposeOf;

      end;

    except

      on e: exception do

        TThread.Synchronize(TThread.CurrentThread,

          procedure

          begin

            MainForm.Memo1.Lines.Add(e.Message);

          end);

    end;

 

  finally

    TThread.Synchronize(TThread.CurrentThread,

      procedure

      begin

        MainForm.ActivityIndicator1.Animate := False;

        MainForm.Button1.Enabled := True;

      end);

    postinstr.DisposeOf;

  end;

end;

下载3次会弹出验证码

var
  postinstr2: TstringList;
  VcodUrl: string;
begin
  try
    try
      postinstr2 := TstringList.Create;
      postinstr2.Add('encrypt=' + '0');
      postinstr2.Add('fid_list=[' + fid_list + ']');
      postinstr2.Add('path_list=');
      postinstr2.Add('primaryid=' + primaryid);
      postinstr2.Add('product=' + 'share');
      postinstr2.Add('uk=' + uk);
      postinstr2.Add('vcode_input=' + vcode_input);
      postinstr2.Add('vcode_str=' + vcode_str);
      postResult2 := Fidhttp.Post(apiurl, postinstr2);
      realUrl := StringReplace(GetMidString(postResult2, 'dlink":"', '",'), '\',
        '', [rfReplaceAll]);
      if realUrl <> '' then
        TThread.Synchronize(TThread.CurrentThread,
          procedure
          begin
            MainForm.Memo1.Lines.Add('百度真实地址为(8小时有效):' + realUrl);
            MainForm.Edit2.Text := realUrl;
          end)
      else
        TThread.Synchronize(TThread.CurrentThread,
          procedure
          begin
            MainForm.Memo1.Lines.Add('获取失败,请尝试重新获取');
          end)
    except
      on e: exception do
        TThread.Synchronize(TThread.CurrentThread,
          procedure
          begin
            MainForm.Memo1.Lines.Add(e.Message);
          end);
    end;

  finally
    TThread.Synchronize(TThread.CurrentThread,
      procedure
      begin
        MainForm.ActivityIndicator1.Animate := False;
        MainForm.Button1.Enabled := True;
        postinstr2.DisposeOf;
      end);
  end;
end;

来源:https://www.amingstudio.com/delphi/368.html

 

相关阅读 >>

Delphi label1 自动尺寸

Delphi xe android的所有权限按照分类总结说明

Delphi利用微软sapi实现语音控制(Delphi,tts,sr,灰色代码)_

Delphi android下拉刷新

Delphi string转换成tstrings

Delphi实现解析百度搜索结果link?url=

Delphi 释放res资源文件

Delphi 金额转大写

Delphi 调用外部程序获取程序id,并能关闭该程序

Delphi定时器相关的简单例子

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...